测试EXTJS4中的特性:config, extend, statics, mixins
2014-05-15 22:27
155 查看
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();
});
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();
});
相关文章推荐
- 测试EXTJS4中的特性:config, extend, statics, mixins
- extjs中的Config及Mixins概念(转)
- EXTJS4自学手册——EXT基本方法、属性(mixins、statics、require)
- Extjs中类的config和statics
- Ext JS 4 新特性2:配置项属性(config)之二
- Spring学习笔记-IOC高级特性3-用Java Config简化XML配置
- Ext JS 混入(Mixins)和配置选项(Config)
- ext之关键字mixins、statics、require
- Win7 IIS配置 applicationHost.config 错误:无法识别的特性“setProfileEnvironment” 解决方法
- 一起学习extjs(四)alias,config,mixins,require用法
- 精进不休 .NET 4.0 (1) - asp.net 4.0 新特性之web.config的改进, ViewStateMode, ClientIDMode, EnablePersistedSelection, 控件的其它一些改进
- ASP.net 4.0 新特性:Web.Config Transformation
- ASP.NET 4.0新特性之Web.config的改进
- ASP.NET 4.0 的新特性(清晰的Web.Config文件)(翻译)
- JS 4 新特性:混合属性(mixins)
- 使用 ConfigSource 特性 拆分 Web.config 文件
- 精进不休 .NET 4.0 (1) - asp.net 4.0 新特性之web.config的改进 推荐
- Spring中JavaConfig特性
- (2)ExtJs4.2 类的定义、继承相关 define extend config constructor alias等
- ASP.NET 4.0 新特性--Web.Config Transformation(原创)