Ext.extend 在 Extjs
예 하나
함수 자료 (설정) { this.name = config.name; this.age = config.age; this.sex = config.sex; } 함수 기반 (설정) { this.identity = config.identity; = config.msg을 this.msg; this.phone = config.phone; base.superclass.constructor.call (이, 구성); } Ext.extend (베이스,베이스, { showMsg : 함수 () { window.alert (this.name + ''+ this.age + ''+ this.sex + ''+ this.identity + ''+ this.msg + ''+ this.phone); } }); VAR mybase = 새로운 거점 ({ 이름 : '', 연령 : '', 성별 : '', 신분 : '', 메시지 : '', 전화 번호 : '' }); mybase.showMsg ();
当 在 这种 情况 下 的 时候

생성자 随后 调用 자료 생성자. 在 EXTJS 中 采用 这种 方式 构造 继承 关系 例如
EXTUTIL.Observable = 함수 () {VAR 나 =이, E = me.events; 경우 (me.listeners) {me.on (me.listeners), 삭제 me.listeners;} me.events = 전자 | | {} ;}; Ext.Component = 기능 (설정) {/ / ... 此处 省略 Ext.Component.superclass.constructor.call (이); / / ... } Ext.extend (Ext.Component, Ext.util.Observable, {/ / ...});
예 둘 :
함수 자료 (설정) { this.name = config.name; this.age = config.age; this.sex = config.sex; } VAR베이스 = Ext.extend (기본, { showMsg : 함수 () { window.alert (this.name + ''+ this.age + ''+ this.sex + ''+ this.identity + ''+ this.msg + '' + this.phone); } }
当 在 这种 情况 下 的 时候

当 VAR mybase = 새로운베이스 (/ ** /); 将会 调用 기본 생성자 函数 此时 자료 是 기지 的 父 类, 实例 化베이스 时 将会 调用 자료 的 생성자. 在 EXTJS 中 采用 这种 方式 构造 继承 关系 例如
Ext.Component = 기능 (설정) { / / ... } Ext.BoxComponent = Ext.extend (Ext.Component, { / / ... });
예 셋
함수 자료 (설정) { this.name = config.name; this.age = config.age; this.sex = config.sex; } VAR베이스 = Ext.extend ({ 생성자 : 기능 (설정) { this.identity = config.identity; = config.msg을 this.msg; this.phone = config.phone; base.superclass.constructor.call (이, 구성); } showMsg : 함수 () { window.alert (this.name + ''+ this.age + ''+ this.sex + ''+ this.identity + ''+ this.msg + '' + this.phone); } }
当 在 这种 情况 下 的 时候

此时 VAR mybase = 새로운베이스 (/ ** /);. 将会 调用 리터럴 객체 中 的 생성자 即 上图中 的 Ext.extend 中 传入 的 생성자 函数
此时 자료 是 기지 的 父 类, 实例 化베이스 时 将会 调用 리터럴 객체 中 的 생성자. 在 EXTJS 中 采用 这种 方式 构 继承 关系 例如
Ext.data.DataWriter = 기능 (설정) { Ext.apply (이, 구성); }; Ext.data.JsonWriter = Ext.extend (Ext.data.DataWriter, { 인코딩 : 사실, encodeDelete : 거짓, 생성자 : 기능 (설정) { Ext.data.JsonWriter.superclass.constructor.call (이, 구성); } / / ... 此处 省略 });
