2015-01-11 154 views
0

我一個項目,我看到:什麼是Ext.apply xtype是什麼意思?

initComponent: function() { 

     var me = this; 

     Ext.apply(me, { 
      items: [ 
       { 
        xtype: 'stockform' 
       } 
      ] 
     }); 

     me.callParent(arguments); 
    } 

這是什麼意思?請告訴我。 我知道Ext.apply()是用來從源簡化許多屬性的複製到目標對象

var x = {a: 1, c:3, e:5}; 
Ext.apply(x, {b:2, d:4, f:6}); 

console.log(x); // Object {a: 1, b: 2, c: 3, d: 4, e: 5, f: 6} 

回答

3

它用於施加給定的屬性定的對象。 在你的情況下,你的組件將會擴展到屬性items,該組件的內部組件的類型爲stockformxtype是shortcat類型。

ExtJs庫中的重要或您的項目中存在具有已定義的xtype stockform的組件。爲組件定義xtype stockform需要通過添加屬性alias: "widget.stockform"

2

這些都是一個兩個問題,其實:

  1. Ext.apply做些什麼?
  2. 什麼是xtype

回覆1:Ext.apply需要(通常)2個對象作爲參數:targetsource並將其複製從源對象的所有屬性到目標對象。

Re 2:xtype是組件(類)別名的短名稱。有關詳細說明,請參閱「What is an xtype ... and other types」文章。