extJs_类定义、继承、多继承、命名空间

来源:互联网 发布:java开发的项目 编辑:程序博客网 时间:2024/06/06 05:19

HelloWord.js:

Ext.onReady(function(){

    Ext.Loader.setConfig({
        enabled: true,
        paths: {
            My: 'resource/js/objBase'  //命名空间
        }
    });
    
    Ext.get("b1").on("click",function(){
        alert(1);

        var first = Ext.create("My.Child2",{
        });
        first.jump();
        
    });
    
});


Child2.js:

Ext.define("My.Child2",{
    extend:"My.Parent",  //继承
    config:{
        c:"c",
    },
    mixins:{                   //多继承
        child:"My.Child1"  
    },
    constructor: function(cfg) {
        this.initConfig(cfg);
    },
    jump:function(){
        alert("Child2-jump-跳崖!!!");
    }
});

Child1.js:
Ext.define("My.Child1",{
    extend:"My.Parent",  //继承
    config:{
        foot:"f",
        eye:"e"
    },
    constructor: function(cfg) {
        this.initConfig(cfg);
    },
    jump:function(){
        alert("Child1-jump-跳崖!!!");
    }

});


Parent.js

Ext.define("My.Parent",{
    config:{
        name:"cc",
        age:null
    },
    constructor: function(cfg) {
        this.initConfig(cfg);
    },
    say:function(){
        alert("王八蛋!!!");
    }
});