Extjs4 定义及继承类

ExtJs4使用Ext.define来定义类:

( String className, Object data, [Function createdFn] ) : Ext.Base

Ext.define and Ext.ClassManager.create are almost aliasesof each other, with the only exception that Ext.define allows definition of overrides.To avoid trouble, always use Ext.define.

Ext.define('My.awesome.Class', {
    someProperty: 'something',
    someMethod: function() { ... }
    ...

}, function() {
    alert('Created!');
    alert(this === My.awesome.Class); // alerts true

    var myInstance = new this();
});

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
  • data : Object

    The key-value pairs of properties to apply to this class. Property names can be of any validstrings, except those in the reserved list below:

  • createdFn : Function (optional)

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

这个方法可以通过extend属性来继承类:

Ext.define('Person', {
    say: function(text) { alert(text); }
});

Ext.define('Developer', {
    extend: 'Person',
    say: function(text) { this.callParent(["print "+text]); }
});

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值