Posted on 2012-04-06 14:32
a_alter 阅读(169)
评论(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