Ext.extend 在 Extjs
Ejemplo uno:
función de la base (config) { this.name = config.name; this.age = config.age; this.sex = config.sex; } función de base (config) { this.identity = config.identity; this.msg = config.msg; this.phone = config.phone; base.superclass.constructor.call (esto, de configuración); } Ext.extend (base, base, { showmsg: function () { window.alert (this.name + '' + this.age + '' + this.sex + '' + this.identity + '' + this.msg + '' + this.phone); } }); var = MyBase nueva base ({ Nombre:'', edad:'', sexo:'', identidad:'', msg:'', teléfono:'' }); mybase.showMsg ();
当 在 这种 情况 下 的 时候

constructor de 随后 调用 constructor base. ExtJS 在 中 采用 这种 方式 构造 继承 关系 例如
EXTUTIL.Observable = function () {var yo = esto, e = me.events, si (me.listeners) {me.on (me.listeners); me.listeners borrado;} me.events = e | | {} ;}; Ext.Component = function (config) {/ / ... 此处 省略 Ext.Component.superclass.constructor.call (this); / / ... Ext.extend} (Ext.Component, Ext.util.Observable, {/ / ...});
Ejemplo dos:
función de la 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); } }
当 在 这种 情况 下 的 时候

当 var = MyBase nueva base (/ ** /); 将会 constructor base 调用 函数 此时 Base 是 base de 的 父 类, 实例 化 base de 时 将会 调用 Base 的 constructor. ExtJS 在 中 采用 这种 方式 构造 继承 关系 例如
Ext.Component = function (config) { / / ... } Ext.BoxComponent = Ext.extend (Ext.Component, { / / ... });
Ejemplo tres:
función de la base (config) { this.name = config.name; this.age = config.age; this.sex = config.sex; } var base = Ext.extend ({ constructor: function (config) { this.identity = config.identity; this.msg = config.msg; this.phone = config.phone; base.superclass.constructor.call (esto, de configuración); }, showmsg: function () { window.alert (this.name + '' + this.age + '' + this.sex + '' + this.identity + '' +'' + + this.msg this.phone); } }
当 在 这种 情况 下 的 时候

此时 var = MyBase nueva base (/ ** /);. 将会 调用 objeto literal 中 的 constructor 即 上图中 的 Ext.extend 中 传入 的 constructor 函数
此时 Base 是 base de 的 父 类, 实例 化 base de 时 将会 调用 objeto literal 中 的 constructor. ExtJS 在 中 采用 这种 方式 构 继承 关系 例如
Ext.data.DataWriter = function (config) { Ext.apply (esto, de configuración); }; Ext.data.JsonWriter = Ext.extend (Ext.data.DataWriter, { codificar: true, encodeDelete: false, constructor: function (config) { Ext.data.JsonWriter.superclass.constructor.call (esto, de configuración); }, / / ... 此处 省略 });
