Ext.extend 在 Extjs
مثال واحد:
قاعدة وظيفة (التكوين) { this.name = config.name؛ this.age = config.age؛ this.sex = config.sex؛ } قاعدة وظيفة (التكوين) { this.identity = config.identity؛ this.msg = config.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)؛ } })؛ فار mybase = قاعدة جديدة ({ الاسم:''، العمر:''، الجنس:''، الهوية:''، رسالة:''، الهاتف:'' })؛ mybase.showMsg ()؛
当 在 这种 情况 下 的 时候

منشئ 随后 调用 منشئ قاعدة. 在 EXTJS 中 采用 这种 方式 构造 继承 关系 例如
EXTUTIL.Observable = وظيفة () {فار لي = هذا، ه = 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؛ } فار = Ext.extend قاعدة (قاعدة، { showMsg: وظيفة () { window.alert (this.name + '' + this.age + '' + this.sex + '' + this.identity + '' +'' + + this.msg this.phone)؛ } }
当 在 这种 情况 下 的 时候

当 فار mybase = قاعدة جديدة (/ ** /)؛ 将会 منشئ قاعدة 调用 函数 此时 قاعدة قاعدة 是 的 父 类، 实例 化 قاعدة 时 将会 调用 قاعدة 的 المنشئ. 在 EXTJS 中 采用 这种 方式 构造 继承 关系 例如
Ext.Component = وظيفة (التكوين) { / / ... } Ext.BoxComponent = Ext.extend (Ext.Component، { / / ... })؛
المثال الثالث:
قاعدة وظيفة (التكوين) { this.name = config.name؛ this.age = config.age؛ this.sex = config.sex؛ } فار قاعدة Ext.extend = ({ المنشئ: وظيفة (التكوين) { this.identity = config.identity؛ this.msg = config.msg؛ this.phone = config.phone؛ base.superclass.constructor.call (هذا، التكوين)؛ }، showMsg: وظيفة () { window.alert (this.name + '' + this.age + '' + this.sex + '' + this.identity + '' +'' + + this.msg this.phone)؛ } }
当 在 这种 情况 下 的 时候

此时 فار mybase = قاعدة جديدة (/ ** /)؛. 将会 调用 الكائن الحرفي 中 的 المنشئ 即 上图中 的 Ext.extend 中 传入 的 المنشئ 函数
此时 قاعدة قاعدة 是 的 父 类، 实例 化 قاعدة 时 将会 调用 الكائن الحرفي 中 的 المنشئ. 在 EXTJS 中 采用 这种 方式 构 继承 关系 例如
Ext.data.DataWriter = وظيفة (التكوين) { Ext.apply (هذا، التكوين)؛ }؛ Ext.data.JsonWriter = Ext.extend (Ext.data.DataWriter، { ترميز: صحيح، encodeDelete: كاذبة، المنشئ: وظيفة (التكوين) { Ext.data.JsonWriter.superclass.constructor.call (هذا، التكوين)؛ }، / / ... 此处 省略 })؛
