簡體   English   中英

ExtJS:未捕獲的TypeError:無法讀取未定義的屬性“作用域”

[英]ExtJS: Uncaught TypeError: Cannot read property 'scope' of undefined

我已經通過此示例創建了一個面板,並且在tools config下有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文件夾中,所以我猜想this符號會引起錯誤。 我應該如何在ViewController中聲明它?

weatherWindow: function () {
        var win = this.lookupReference('weatherWindow');

        if (!win) {
            win = new MyApp.view.weather.SettingsWindow();
            this.getView().add(win);
        }

        win.show();
    },

更新我已經為視圖創建了一個ViewController ,但是仍然給出scope錯誤!

Ext.define('MyApp.view.dash.WeatherView', {
    extend: 'Ext.panel.Panel',
    xtype: 'weatherview',

    requires: [
        'MyApp.view.dash.WeatherViewVC',

    ],

    controller: 'weatherView',

//and..
Ext.define('MyApp.view.dash.WeatherViewVC', {
    extend: 'Ext.app.ViewController',
    alias: 'controller.weatherView',

    requires: [],

    weatherWindow: function () {
        debugger;

        var win = this.lookupReference('settingsWindow');

        if (!win) {
            win = new MyApp.view.weather.SettingsWindow();
            this.getView().add(win);
        }

        win.show();
    },

我已找到此錯誤的解決方案。 在window類中創建一個函數並返回它;

getSettingsItems: function () {
    var me = this;

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

    return settingsItems;
},

暫無
暫無

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

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