[英]Extjs5 treepanel [Uncaught TypeError: Cannot read property 'create' of undefined]
[英]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.