译自:http://docs.sencha.com/extjs/4.2.3/#!/api/Ext
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值被赋予了特殊的意义,具体参考官网说明。