EXTJS4官方文档翻译系列一:类系统和编码规范
发布时间:2018-11-06 14:32:31  所属栏目:模式  来源:站长网 
            导读:副标题#e# EXTJS4官方文档翻译系列一:类系统和编码规范,转载自《学而知不足》的技术博客,原文如下: 上个礼拜开始使用extjs4,之前都没用过ext,所以现在只好努力的看文档了,顺便记下来避免以后忘记.括号中内容是我自己添加的备注或者原文.英语比较烂,但不
                
                
                
            | 静态成员可以使用statics配置项来定义    1: Ext.define('Computer', {   2:     statics: {3: instanceCount: 0,    4:         factory: function(brand) {5: // 'this' in static methods refer to the class itself    6:             return new this({brand: brand});7: } 8: }, 9:   10:     config: {11: brand: null 12: }, 13:   14:     constructor: function(config) {15: this.initConfig(config); 16: 17: // the 'self' property of an instance refers to its class 18: this.self.instanceCount ++; 19: 20: return this; 21: } 22: }); 23:   24: var dellComputer = Computer.factory('Dell');  25: var appleComputer = Computer.factory('Mac');26: 27: alert(appleComputer.getBrand()); // using the auto-generated getter to get the value of a config property. Alerts "Mac" 28: 29: alert(Computer.instanceCount); // Alerts "2" 四.错误处理&调试 Extjs 4包含一些有用的特性用于调试和错误处理. 
    1: throw new Error('['+ Ext.getDisplayName(arguments.callee) +'] Some message here');当使用Ext.define()定义的类中的方法抛出异常后.你将在调用堆栈中看到类和方法名(如果你使用webkit).例如,以下是chrome浏览器的效果: 
 
 (编辑:宣城站长网) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! | 

