ExtJs-Ext.extend函数的使用

Ext.extend 在 ExtJs

Voorbeeld een:

 functie Base (config) {
   this.name = config.name;
   this.age = config.age;
   this.sex = config.sex;
 }

 functie basis (config) {
  this.identity = config.identity;
  this.msg = config.msg;
  this.phone = config.phone;

  base.superclass.constructor.call (dit, config);
 }

 Ext.extend (basis, Base, {
    showMsg: function () {
      window.alert (this.name + '' + this.age + '' + this.sex + '' + this.identity + '' + this.msg + '' + this.phone);
    }
 });

  var MyBase = nieuwe basis ({
        naam:'',
        leeftijd:'',
        geslacht:'',
        identiteit:'',
        msg:'',
        telefoon:''
  });
  mybase.showMsg ();

当 在 这种 情况 下 的 时候

constructeur 随后 调用 Base constructor. 在 ExtJs 中 采用 这种 方式 构造 继承 关系 例如

 EXTUTIL.Observable = function () {var me = dit, e = me.events if (me.listeners) {me.on (me.listeners), verwijderen me.listeners;} me.events = e | | {} ;}; Ext.Component = function (config) {/ / ... 此处 省略 Ext.Component.superclass.constructor.call (this); / / ...  } Ext.extend (Ext.Component, Ext.util.Observable, {/ / ...}); 

Voorbeeld twee:

 functie Base (config) {
 this.name = config.name;
 this.age = config.age;
 this.sex = config.sex;
  }

  var basis = Ext.extend (Base, {
    showMsg: function () {
      window.alert (this.name + '' + this.age + '' + this.sex + '' + this.identity + '' + this.msg +'' + this.phone);
    }
 }

当 在 这种 情况 下 的 时候

 当 var MyBase = nieuwe basis (/ ** /); 将会 调用 Base constructeur 函数 

此时 Base 是 basis 的 父 类, 实例 化 basis 时 将会 调用 Base 的 constructor. 在 ExtJs 中 采用 这种 方式 构造 继承 关系 例如

 Ext.Component = function (config) {

   / / ...
 }

 Ext.BoxComponent = Ext.extend (Ext.Component, {

  / / ...
 });

Voorbeeld drie:

 functie Base (config) {
 this.name = config.name;
 this.age = config.age;
 this.sex = config.sex;
  }

 var basis = Ext.extend ({
     bouwer: functie (config) {
	    this.identity = config.identity;
	    this.msg = config.msg;
	    this.phone = config.phone;

	    base.superclass.constructor.call (dit, config);
 }
 showMsg: function () {
 window.alert (this.name + '' + this.age + '' + this.sex + '' + this.identity + '' + this.msg +'' + this.phone);
    }
 }

当 在 这种 情况 下 的 时候

 此时 var MyBase = nieuwe basis (/ ** /);. 将会 调用 letterlijke object 中 的 constructeur 即 上图中 的 Ext.extend 中 传入 的 constructeur 函数

此时 Base 是 basis 的 父 类, 实例 化 basis 时 将会 调用 letterlijke object 中 的 constructor. 在 ExtJs 中 采用 这种 方式 构 继承 关系 例如

 Ext.data.DataWriter = function (config) {
     Ext.apply (dit, config);
 };

 Ext.data.JsonWriter = Ext.extend (Ext.data.DataWriter, {

     coderen: true,

     encodeDelete: false,

     bouwer: functie (config) {
         Ext.data.JsonWriter.superclass.constructor.call (dit, config);
     }

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

Deel dit bericht:
Digg Google Bookmarks reddit Mixx StumbleUpon Technorati Yahoo! Buzz DesignFloat Heerlijk BlinkList Opvouwen

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

Laat een reactie achter:

Naam (verplicht):
Mail (zal niet worden gepubliceerd) (verplicht):
Website:
Reactie (verplicht):
XHTML: Je kan deze tags gebruiken: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>