Ext.extend 在 ExtJs
Voorbeeld een:
functie Base (config) { this.name = config.name; this.age = config.age; this.sex = config.sex; } functie basis (config) { this.identity = config.identity; this.msg = config.msg; this.phone = config.phone; base.superclass.constructor.call (dit, config); } Ext.extend (basis, Base, { showMsg: function () { window.alert (this.name + '' + this.age + '' + this.sex + '' + this.identity + '' + this.msg + '' + this.phone); } }); var MyBase = nieuwe basis ({ naam:'', leeftijd:'', geslacht:'', identiteit:'', msg:'', telefoon:'' }); mybase.showMsg ();
当 在 这种 情况 下 的 时候

constructeur 随后 调用 Base constructor. 在 ExtJs 中 采用 这种 方式 构造 继承 关系 例如
EXTUTIL.Observable = function () {var me = dit, e = me.events if (me.listeners) {me.on (me.listeners), verwijderen me.listeners;} me.events = e | | {} ;}; Ext.Component = function (config) {/ / ... 此处 省略 Ext.Component.superclass.constructor.call (this); / / ... } Ext.extend (Ext.Component, Ext.util.Observable, {/ / ...});
Voorbeeld twee:
functie Base (config) { this.name = config.name; this.age = config.age; this.sex = config.sex; } var basis = Ext.extend (Base, { showMsg: function () { window.alert (this.name + '' + this.age + '' + this.sex + '' + this.identity + '' + this.msg +'' + this.phone); } }
当 在 这种 情况 下 的 时候

当 var MyBase = nieuwe basis (/ ** /); 将会 调用 Base constructeur 函数 此时 Base 是 basis 的 父 类, 实例 化 basis 时 将会 调用 Base 的 constructor. 在 ExtJs 中 采用 这种 方式 构造 继承 关系 例如
Ext.Component = function (config) { / / ... } Ext.BoxComponent = Ext.extend (Ext.Component, { / / ... });
Voorbeeld drie:
functie Base (config) { this.name = config.name; this.age = config.age; this.sex = config.sex; } var basis = Ext.extend ({ bouwer: functie (config) { this.identity = config.identity; this.msg = config.msg; this.phone = config.phone; base.superclass.constructor.call (dit, config); } showMsg: function () { window.alert (this.name + '' + this.age + '' + this.sex + '' + this.identity + '' + this.msg +'' + this.phone); } }
当 在 这种 情况 下 的 时候

此时 var MyBase = nieuwe basis (/ ** /);. 将会 调用 letterlijke object 中 的 constructeur 即 上图中 的 Ext.extend 中 传入 的 constructeur 函数
此时 Base 是 basis 的 父 类, 实例 化 basis 时 将会 调用 letterlijke object 中 的 constructor. 在 ExtJs 中 采用 这种 方式 构 继承 关系 例如
Ext.data.DataWriter = function (config) { Ext.apply (dit, config); }; Ext.data.JsonWriter = Ext.extend (Ext.data.DataWriter, { coderen: true, encodeDelete: false, bouwer: functie (config) { Ext.data.JsonWriter.superclass.constructor.call (dit, config); } / / ... 此处 省略 });
