2013-07-09 32 views
-1

我正在開發一個煎茶觸摸應用程序,如果可以做這樣的事情,這將是巨大的:如何將一個屬性從父項屬性轉換爲javascript中的子項? (OOP)

Ext.define('PUREM.view.screen.Form', { 
    person : null, 
    items : [ 
     {xtype: 'mycomponent', person: parent.person} 
    ] 
}); 

顯然這個代碼不起作用。我想知道如何使它工作,如果有一種方法來使用子對象(xtype:'mycomponent')中父對象的「person」屬性。

+0

你有問題要問? – kevhender

+0

顯然這個代碼不起作用。我想知道如何使它工作,如果有一種方法來使用子對象(xtype:'mycomponent')中父對象的「person」屬性。 –

回答

0

在您的班級定義中,您應該覆蓋initComponent函數。然後你將有權訪問該對象的所有屬性。

Ext.define('PUREM.view.screen.Form', { 
    extend: 'Ext.form.Panel', 
    config: { 
     person : null 
    }, 

    initComponent: function() 
    { 
     var me = this; 
     me.items = [ 
      {xtype: 'mycomponent', person: me.person} 
     ] 

     me.callParent(arguments); 
    } 
}); 
+0

這個工作很好。謝謝^^ –

相關問題