Extjs-Ext.extend函数的使用

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);
     },

    / / ... 此处 省略
 });

Comparte este artículo:
Digg Google Bookmarks reddit Mixx StumbleUpon Technorati Yahoo! Buzz DesignFloat Delicioso BlinkList Furl

No Responses to "Extjs-Ext.extend 函数 的 使用"

Deja un comentario:

Nombre (requerido):
Mail (no será publicado) (requerido):
Sitio Web:
Comentario (obligatorio):
XHTML: Puedes usar las siguientes etiquetas: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>