加入收藏 | 设为首页 | 会员中心 | 我要投稿 湖南网 (https://www.hunanwang.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 创业 > 正文

EXTJS4官方文档翻译系列一:类系统和编码规范

发布时间:2018-11-06 05:44:26 所属栏目:创业 来源:站长网
导读: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包括一些有效的特征用于调试和错误处理赏罚.

  • 你可以行使Ext.getDisplayName()来表现恣意要领的名字.这对表现抛出非常的类和要领很是有效.
   1: throw new Error('['+ Ext.getDisplayName(arguments.callee) +'] Some message here');

当行使Ext.define()界说的类中的要领抛出非常后.你将在挪用仓库中看到类和要领名(假如你行使webkit).譬喻,以下是chrome赏识器的结果:

 

EXTJS4官方文档翻译系列一:类体系和编码类型

(编辑:湖南网)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

热点阅读