我如何在extjs中访问这个内部项目

how can i access this inside items in extjs

本文关键字:内部 项目 访问 extjs      更新时间:2023-09-26

我有这样的代码

Ext.define('Header', {
getItems: function() {
    return somepanel;
}
items: [this.getItems()]
});

这是不工作。

你的问题有点模糊,但是,你可以添加一个模板方法:

Ext.define('MyContainer', {
    extend: 'Ext.container.Container',
    initComponent: function() {
        this.items = this.createItems();
        this.callParent();
    },
    createItems: function() {
        return [{title: 'Foo'}];
    }
});

this是Ext.define('Header'…)被执行的上下文。我猜那是窗口

我不明白你想做什么,但是如果你想用函数填充item属性,你需要调用它:

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