簡體   English   中英

我如何在extjs中訪問此內部項目

[英]how can i access this inside items in extjs

我有這個代碼

Ext.define('Header', {

getItems: function() {
    return somepanel;
}

items: [this.getItems()]

});

這是行不通的。 我收到未定義getItems的錯誤

您的問題有點含糊,但是,您可以添加模板方法:

Ext.define('MyContainer', {
    extend: 'Ext.container.Container',

    initComponent: function() {
        this.items = this.createItems();
        this.callParent();
    },

    createItems: function() {
        return [{title: 'Foo'}];
    }
});

是執行Ext.define('Header'...)的上下文。 我想那是窗戶

我沒有正確地知道您想做什么,但是如果您想用功能填充item屬性,則需要調用它:

items: function() {
    return somepanel;
}()

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM