extjs的Ext.define()函数的用法以及注意点。

译自:http://docs.sencha.com/extjs/4.2.3/#!/api/Ext

className, data, [createdFn] ) :  Ext.Base

Defines a class or override. A basic class is defined like this:

 Ext.define('My.awesome.Class', {
     someProperty: 'something',

     someMethod: function(s) {
         alert(s + this.someProperty);
     }

     ...
 });

 var obj = new My.awesome.Class();

 obj.someMethod('Say '); // alerts 'Say something'

Parameters

  • className : String

    The class name to create in string dot-namespaced format, for example: 'My.very.awesome.Class', 'FeedViewer.plugin.CoolPager' It is highly recommended to follow this simple convention: - The root and the class name are 'CamelCased' - Everything else is lower-cased Pass null to create an anonymous class.

  • data : Object

    The key - value pairs of properties to apply to this class. Property names can be of any valid strings, except those in the reserved listed below: - mixins -statics - config - alias - xtype (for Components only) - self - singleton - alternateClassName - override

  • createdFn : Function (optional)

    Callback to execute after the class is created, the execution scope of which (this) will be the newly created class itself.

Returns

注意:参数集中的 data选项的key值(数据名)是有限制的,如下关键字不可用:

data : Object

The key - value pairs of properties to apply to this class. Property names can be of any valid strings, except those in the reserved listed below: - mixins -statics - config - alias - xtype (for Components only) - self - singleton - alternateClassName - override

即:

mixins -statics - config - alias - xtype (for Components only) - self - singleton - alternateClassName - override

当然还包括其子类的属性和所有类的基类Ext.Base的所有属性,比如Ext.Base.extend   即如extend:'Ext.tree.Panel',


这些关键字不可用,因为这些key值被赋予了特殊的意义,具体参考官网说明。




  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值