您的位置:首页 > Web前端 > JavaScript

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

2016-10-14 16:33 423 查看
译自:http://docs.sencha.com/extjs/4.2.3/#!/api/Ext

define( 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

Ext.Base

注意:参数集中的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值被赋予了特殊的意义,具体参考官网说明。




内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: