1 , alias : 至关于别名同样,能够起多个,能够经过xtype和Ext.widget()建立实例: html
- Ext.define('SimplePanel', {
- extend: 'Ext.panel.Panel',
- alias: ['widget.simplepanel_007','widget.simplepanel_008'],
- title: 'Yeah!'
- });
-
- //经过Ext.widget()建立实例
- Ext.widget('simplepanel_007',{
- width : 100,
- height : 100
- }).render(Ext.getBody());
-
- //经过xtype建立
- Ext.widget('simplepanel_007', {
- width : 100,
- items: [
- {xtype: 'simplepanel_008', html: 'Foo'},
- {xtype: 'simplepanel_008', html: 'Bar'}
- ]
- }).render(Ext.getBody());
2 , alternateClassName : 跟alias有点相似,至关于给类找替身,能够多个,能够经过Ext.create()建立实例: ui
- Ext.define('Boy', {
- //定义多个替身
- alternateClassName: ['boy2', 'boy3'],
- say : function(msg){
- alert(msg);
- }
- });
-
- var boy1 = Ext.create('Boy');
- boy1.say('I am boy1...');
-
- //能够经过alternateClassName实例化该类
- var boy2 = Ext.create('boy2');
- boy2.say('I am boy2...');
-
- var boy3 = Ext.create('boy3');
- boy3.say('I am boy3...');
3 , config:类的属性配置,属性能够自动生成geter/seter方法 this
- Ext.define('Boy', {
- config : {
- name : 'czp',
- age : 25
- },
- constructor: function(cfg) {
- this.initConfig(cfg);
- }
- });
-
- var czp = Ext.create('Boy',{name:'czpae86'});
- //经过getName()方法得到属性name值
- alert(czp.getName());
- //经过setAge()方法改变属性age值
- czp.setAge(25.5);
4 , extend : 继承,能够继承单个类 spa
- Ext.define('Person', {
- say: function(text) { alert(text); }
- });
- Ext.define('Boy', {
- extend : 'Person'
- });
-
- var czp = Ext.create('Boy');
- //继承了Person,因此能够使用say()方法
- czp.say('my name is czp.');
5 , inheritableStatics : 定义静态方法,能够经过"类名.方法名"调用静态方法. 相似 statics属性, .net
区别是:子类也能够使用该静态方法,但statics属性定义的静态方法子类是不会继承的. htm
- Ext.define('Person', {
- inheritableStatics : {
- sleep : function(){
- alert('sleep');
- }
- },
- say: function(text) { alert(text); }
- });
-
- Ext.define('Boy', {
- extend : 'Person'
- });
-
- //子类能够经过"类名.方法名"调用父类经过"inheritableStatics"定义的方法
- Boy.sleep();
6 , mixins : 能够实现多继承 blog
- Ext.define('Person', {
- say: function(text) { alert(text); }
- });
-
- Ext.define('Boy', {
- play : function(){
- alert('play');
- }
- });
-
- Ext.define('Gird', {
- sleep : function(){
- alert('sleep');
- }
- });
-
- Ext.define('A_007', {
- //继承Person
- extend : 'Person',
- //同时继承'Boy','Gird'
- mixins : ['Boy','Gird']
- });
-
- var a_007 = new A_007();
- a_007.say('我能够say,也能够play,还能够sleep!!');
- a_007.play();
- a_007.sleep();
7 , singleton : 建立单例模式的类, 若是singleton为true,那么该类不能用经过new建立,也不能被继承 继承
- Ext.define('Logger', {
- //singleton为true
- singleton: true,
- log: function(msg) {
- alert(msg);
- }
- });
- //方法调用"类名.方法名"
- Logger.log('Hello');
8 , statics : 与第5个inheritableStatics属性相似,statics属性定义的静态方法子类是不会继承的.请看第5个属性. get
9 , uses 和 requires : 与requires属性相似,都是对某些类进行引用 it
uses -- 被引用的类能够在该类以后才加载.
requires -- 被引用的类必须在该类以前加载.
- Ext.define('Gird', {
- uses : ['Boy'],
- getBoy : function(){
- return Ext.create('Boy');
- },
- sleep : function(){
- alert('sleep');
- }
- });
-
- //对于uses属性,Boy类放在后面是能够的,不会报错
- Ext.define('Boy', {
- play : function(){
- alert('play');
- }
- });
-
-
- //对于requires属性,Boy类必须在Grid类以前加载,否则会报错
- Ext.define('Boy', {
- play : function(){
- alert('play');
- }
- });
-
- Ext.define('Gird', {
- requires : ['Boy'],
- getBoy : function(){
- return Ext.create('Boy');
- },
- sleep : function(){
- alert('sleep');
- }
- });