Posted on 2012-04-06 14:32
a_alter 閱讀(176)
評論(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 , 不過支持多繼承。 相同方法取最后實現。
Statics
靜態字段和方法定義塊。
Ext.define('Person',{
statics:{
staticAttribute:'靜態變量',
staticFunction:function(){
// 靜態方法
}
}
});
alert(Person.staticAttribute);
Config
這個理解為 java 的pojo中的變量, 可以自動生成以下方法, 以下代碼摘官方文檔。
usage
Ext.define('MyClass', {
config: {
title: 'Default Title'
}
});
自動生成以下代碼
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);
}
檢測用戶的使用環境 相關見API文檔
- Ext.env.Browser
- Ext.env.FeatureDetector
- Ext.env.OS