extjs4: class system
来源:互联网 发布:js函数传对象参数 编辑:程序博客网 时间:2024/05/01 22:09
一:Configuration的用法
Ext.define('My.first.Person',{ name : 'zhangsan', age : 20, // 1. 封装成员 // 2. 提供 'getter' ,'setter'方法; // 3. 为每个config内的成员生成apply方法,这个方法在setter赋值前可以进行处理。 config : { email : 'zhangsan@163.com', others : { height : 180, belongsTo : 'china', } }, /*constructor : function(name, age){ if(name){ // 在创建实例时如果不传参数,会有默认的null参数传进来,所以要判断 this.name = name; } if(age){ this.age = age; } },*/ constructor : function(config){ this.initConfig(config); }, applyEmail : function( aEmail ){ if(!aEmail){ alert('invalid email'); }else{ return aEmail; // 如果apply不返回参数,则setter不进行设置。 } }, say : function(something){ alert( this.name + ' say ' + something + ' when he ' + this.age + ' years old!'); } }); var a = Ext.create('My.first.Person', 'lilei', '20'); //a.say('what'); a.setEmail('tupiku@yahoo.com'); //alert(a.getEmail()); a.setOthers({height:200, belongsTo:'Beijing'}); //alert(a.getOthers().height); var b = Ext.create('My.first.Person',{ name : 'jack', email : 'jack@soho.com', }) ///类中没有被config包裹的成员,不能被赋值 alert(b.name); // 'zhangsan' alert(b.email); // 'jack@soho.com'
二:statices的用法
Ext.define('Computer',{ config : { brand : 'ASUS', }, statics : { instanceCount : 0, factory : function(computerBrand){ //静态方法中的this代表类本身 return new this({brand : computerBrand}); } }, constructor : function(config){ this.initConfig(config); this.self.instanceCount++; // self表示this的类 } }); dellComputer = Computer.factory('dell'); macComputer = Computer.factory('mac'); alert(macComputer.getBrand()); alert(Computer.instanceCount);
- extjs4: class system
- 一步一步翻译,解说extjs4-------------Class System
- Extjs4 API文档阅读(一)——类系统(Class System)
- Extjs4 API文档阅读(一)——类系统(Class System)
- Extjs4 API文档阅读(一)——类系统(Class System)
- Extjs4 API文档阅读(一)——类系统(Class System)
- Extjs4.0 Ext.Class
- extjs4 row Class
- Ext JS.4.0:动态加载和新的类系统(countDown of Extjs4.0: Dynamic Loading and New Class System)
- xtype与Extjs4控件Class对应表
- System.class.getResourceAsStream分析
- Python Class System
- System class 源码解读
- Class System 方法学习
- 23.2 The System.Exception class
- Ext js 6 - Class System
- extjs4
- extjs4的Ext.Class的alias Config options
- 我们都一样
- 二分图匹配 H-K 算法
- Qt使用phonon单曲循环
- Android界面开发推荐颜色
- Oracle 回滚表记录
- extjs4: class system
- puppet完全攻略(一)puppet应用原理及安装部署
- POI操作隐藏的Excel
- 软件设计,在大在小
- Android C2DM学习 --云端推送
- Android 布局文件属性讲解
- 经济不景气了,程序员有没有感觉到
- 编程无趣,给大家来道菜
- c++强制类型转换