ExtJS:未捕获的TypeError:无法读取未定义的属性“范围”

时间:2018-01-15 11:31:03

标签: javascript function extjs scope viewcontroller

我已通过此sample创建了一个面板,它在tools配置下有2个项目。这两个项目都有自己的功能,通过ViewController绑定。 refresh项的功能运行良好,但gear项的功能在下面给出了这个错误;

Uncaught TypeError: Cannot read property 'scope' of undefined
    at constructor.addListener (Observable.js?_dc=1516015518102:1135)
    at constructor (Observable.js?_dc=1516015518102:403)
    at constructor.beforeInitConfig (Component.js?_dc=1516015518101:2261)
    at Ext.Configurator.configure (Configurator.js?_dc=1516015518102:558)
    at constructor.initConfig (Base.js?_dc=1516015518101:1554)
    at constructor (Component.js?_dc=1516015518101:2137)
    at new constructor (Class.js?_dc=1516015518101:42)
    at Object.widget (ClassManager.js?_dc=1516015518101:1638)
    at constructor.create (ComponentManager.js?_dc=1516015518102:76)
    at constructor.lookupComponent (Container.js?_dc=1516015518101:1564)

我已将视图类从app文件夹移动到classic文件夹,但ViewController类保留在app文件夹中,所以我猜错误是通过{{ 1}}符号。我应该如何在ViewController中声明它?

this

更新 我为视图创建了weatherWindow: function () { var win = this.lookupReference('weatherWindow'); if (!win) { win = new MyApp.view.weather.SettingsWindow(); this.getView().add(win); } win.show(); }, 但仍然出现ViewController错误!

scope

1 个答案:

答案 0 :(得分:0)

我找到了解决此错误的方法。在窗口类中创建了一个函数并返回它;

getSettingsItems: function () {
    var me = this;

    var settingsItems = [
        // whole items listed here!
    ];

    return settingsItems;
},