Ext.onReady(function() { alert("测试 config"); //测试 config //构造一台智能手机 Ext.define('SmartPhone', {
Ext.onReady(function() {
alert("测试 config");
//测试 config
//构造一台智能手机
Ext.define('SmartPhone', {
config: {
hasTouchScreen: false,//有触摸屏
operatingSystem: 'Other',//操作系统
price: 500//价格
},
constructor: function(cfg) {
this.initConfig(cfg);
}
});
//iPhone手机
var iPhone = new SmartPhone({
hasTouchScreen: true,
operatingSystem: 'iOS'
});
alert( iPhone.getOperatingSystem());
alert(iPhone.getHasTouchScreen());
//Ext.Msg.alert('iPhone.getPrice():', iPhone.getPrice());
alert("测试 extend");
//测试 extend
//构造人类
Ext.define('Person', {
say: function(text) { alert(text); }//具有说的方法
});
Ext.define('Developer', {
extend: 'Person',//继承人类
say: function(text) { this.callParent(["print "+text]); }//继承了说的方法
});
var develop = new Developer();
develop.say("text");
alert("测试 static");
//测试 static
//构造一台计算机
Ext.define('Computer', {
statics: {
factory: function(brand) {
alert(brand);
}
},
constructor: function() { }//构造函数
});
//创建一台戴尔电脑
var dellComputer = Computer.factory('Dell');
alert("测试 mixins");
//测试 mixins
//唱歌
Ext.define('CanSing', {
sing: function() {
alert("sing()")
}
});
//音乐家
Ext.define('Musician', {
mixins: ['CanSing']
});
var m = new Musician();
m.sing();
});