Posted on 2012-04-06 14:32
a_alter 閱讀(172)
評(píng)論(0) 編輯 收藏 所屬分類:
ExtJs
Mixins
官方文檔介紹
This is a new approach to plugging custom functionality into existing classes. The new mixins config, included during instantiation of a class, allows you to "mix in" new capabilities to the class prototype. This is similar to the existing Ext.override function, although it does not replace existing methods like override does, it simply augments the prototype with whatever is new.
== java override , 不過(guò)支持多繼承。 相同方法取最后實(shí)現(xiàn)。
Statics
靜態(tài)字段和方法定義塊。
Ext.define('Person',{
statics:{
staticAttribute:'靜態(tài)變量',
staticFunction:function(){
// 靜態(tài)方法
}
}
});
alert(Person.staticAttribute);
Config
這個(gè)理解為 java 的pojo中的變量, 可以自動(dòng)生成以下方法, 以下代碼摘官方文檔。
usage
Ext.define('MyClass', {
config: {
title: 'Default Title'
}
});
自動(dòng)生成以下代碼
title: 'Default Title',
getTitle: function() {
return this.title;
},
resetTitle: function() {
this.setTitle('Default Title');
},
setTitle: function(newTitle) {
this.title = this.applyTitle(newTitle) || newTitle;
},
applyTitle: function(newTitle) {
// custom code here
// e.g. Ext.get('titleEl').update(newTitle);
}
檢測(cè)用戶的使用環(huán)境 相關(guān)見(jiàn)API文檔
- Ext.env.Browser
- Ext.env.FeatureDetector
- Ext.env.OS