未捕获的TypeError:controller.setView不是EXTJS中的函数

时间:2019-06-19 09:37:18

标签: javascript extjs

我想在单击按钮时重定向/弹出表单 我将按钮处理程序命名为OnRoutesClick 但我遇到了一些错误

请帮助我找出错误 预先感谢您screenshot of error in browser

reportMenuController.js

Ext.define('Traccar.view.reportMenuController', {
    extend:'Ext.app.ViewController',
    alias:'controller.reportMenu',

requires:[
'Traccar.view.dialog.Server',
'Traccar.view.dialog.User',
'Traccar.view.dialog.reportBox'
],

onRoutesClick: function () {
        var dialog = Ext.create('Traccar.view.dialog.reportBox', {
            selfEdit: true
        });
        dialog.down('form').loadRecord(Traccar.app.getUser());
        dialog.lookupReference('testNotificationButton').setHidden(false);
        dialog.show();
    },

reportBox.js

Ext.define('Traccar.view.dialog.reportBox', {
    extend:'Traccar.view.dialog.BaseEdit',

requires: [
'Traccar.view.ClearableComboBox',
'Traccar.view.dialog.reportBoxController',
'Traccar.view.UnescapedTextField'
],

controller:'reportBox',
title:'Report',
text:'Report',


items:{
    xtype:'form',
   items: [{
    xtype:'fieldset',
    title:Strings.sharedRequired,
    items:[{
        xtype:'unescapedTextField',
        fieldLabel:'name'
    }]
   }]
}
});

浏览器错误

Uncaught TypeError: controller.setView is not a function
    at constructor.applyController (ext-all-debug.js:53043)
    at constructor.setter [as setController] (ext-all-debug.js:10545)
    at Ext.Configurator.configure (ext-all-debug.js:11134)
    at constructor.initConfig (ext-all-debug.js:12643)
    at constructor (ext-all-debug.js:66310)
    at new constructor (ext-all-debug.js:13136)
    at eval (eval at getInstantiator (ext-all-debug.js:15045), <anonymous>:3:8)
    at Object.create (ext-all-debug.js:15489)
    at constructor.onRoutesClick (reportMenuController.js:50)
    at Object.callback (ext-all-debug.js:8705)

1 个答案:

答案 0 :(得分:0)

  1. 在视图中,应针对控制器密钥提及控制器别名。 因此,由于您的别名是'reportMenu',因此必须提及相同的内容。
Ext.define('Traccar.view.dialog.reportBox', {
    extend:'Traccar.view.dialog.BaseEdit',

requires: [
'Traccar.view.ClearableComboBox',
'Traccar.view.dialog.reportBoxController',
'Traccar.view.UnescapedTextField'
],

controller:'reportMenu',
title:'Report',
text:'Report',


items:{
    xtype:'form',
   items: [{
    xtype:'fieldset',
    title:Strings.sharedRequired,
    items:[{
        xtype:'unescapedTextField',
        fieldLabel:'name'
    }]
   }]
}
});
  1. 您的控制器应与视图位于同一级别的文件夹中。