Ext.extend 在 ExtJS
Beispiel eins:
Funktion Base (config) { this.name = config.name; this.age = config.age; this.sex = config.sex; } Basis-Funktion (config) { this.identity = config.identity; this.msg = config.msg; this.phone = config.phone; base.superclass.constructor.call (this, config); } Ext.extend (Base, Base, { ShowMsg: function () { window.alert (this.name + '' + this.age + '' + this.sex + '' + this.identity + '' + this.msg + '' + this.phone); } }); var = new MyBase Basis ({ Name:'', Alter:'', Geschlecht:'', Identität:'', msg:'', Telefon:'' }); mybase.showMsg ();
当 在 这种 情况 下 的 时候

Konstruktor 随后 调用 Basiskonstruktor. 在 ExtJS 中 采用 这种 方式 构造 继承 关系 例如
EXTUTIL.Observable = function () {var me = dies, e = me.events; if (me.listeners) {me.on (me.listeners); delete me.listeners;} me.events = e | | {} ;}; Ext.Component = function (config) {/ / ... 此处 省略 Ext.Component.superclass.constructor.call (this); / / ... Ext.extend} (Ext.Component, Ext.util.Observable, {/ / ...});
Beispiel zwei:
Funktion Base (config) { this.name = config.name; this.age = config.age; this.sex = config.sex; } var base = Ext.extend (Base, { ShowMsg: function () { window.alert (this.name + '' + this.age + '' + this.sex + '' + this.identity + '' +'' + + this.msg this.phone); } }
当 在 这种 情况 下 的 时候

当 MyBase var = new Basis (/ ** /); 将会 调用 Basiskonstruktor 函数 此时 Basis 是 Basis 的 父 类, 实例 化 Basis 时 将会 调用 Basis 的 Konstruktor. 在 ExtJS 中 采用 这种 方式 构造 继承 关系 例如
Ext.Component = function (config) { / / ... } Ext.BoxComponent = Ext.extend (Ext.Component, { / / ... });
Beispiel drei:
Funktion Base (config) { this.name = config.name; this.age = config.age; this.sex = config.sex; } var base = Ext.extend ({ Konstruktor: function (config) { this.identity = config.identity; this.msg = config.msg; this.phone = config.phone; base.superclass.constructor.call (this, config); }, ShowMsg: function () { window.alert (this.name + '' + this.age + '' + this.sex + '' + this.identity + '' +'' + + this.msg this.phone); } }
当 在 这种 情况 下 的 时候

此时 MyBase var = new Basis (/ ** /);. 将会 调用 wörtliche Objekt 中 的 Konstruktor 即 上图中 的 Ext.extend 中 传入 的 Konstruktor 函数
此时 Basis 是 Basis 的 父 类, 实例 化 Basis 时 将会 调用 wörtliche Objekt 中 的 Konstruktor. 在 ExtJS 中 采用 这种 方式 构 继承 关系 例如
Ext.data.DataWriter = function (config) { Ext.apply (dies, config); }; Ext.data.JsonWriter = Ext.extend (Ext.data.DataWriter, { kodieren: true, encodeDelete: false, Konstruktor: function (config) { Ext.data.JsonWriter.superclass.constructor.call (this, config); }, / / ... 此处 省略 });
