侧边栏壁纸
博主头像
落叶人生博主等级

走进秋风,寻找秋天的落叶

  • 累计撰写 130562 篇文章
  • 累计创建 28 个标签
  • 累计收到 9 条评论
标签搜索

目 录CONTENT

文章目录

测试EXTJS4中的特性:config, extend, statics, mixins

2024-05-11 星期六 / 0 评论 / 0 点赞 / 76 阅读 / 2393 字

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();
});

广告 广告

评论区