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:
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("王八蛋!!!");
}
});
本文通过一个具体的示例介绍了如何在ExtJS中使用多继承和混合(mixins)来扩展组件的功能。示例中创建了多个类,包括父类`My.Parent`以及子类`My.Child1`和`My.Child2`,并通过`Ext.create`实例化子类对象,展示了如何调用其方法。
2180

被折叠的 条评论
为什么被折叠?



