我无法在viewController中获取Ext.MessageBox的实例

问题描述

Ext.define('mondernTunes.view.main.MainView',{
    extend: 'Ext.Container',xtype: 'mainview',controller: 'MyMainViewController',viewmodel: {
        type: 'mainviewmodel'
    },items: [{
        xtype: 'component',html: '<a style="font-size:24px" target="_blank" href="https://docs-devel.sencha.com/extjs/7.0.0-CE/guides/quick_start/What_You_Will_Be_Coding.html">Quick Start Tutorial Here</a><p>'
    },{
        xtype: 'displayfield',reference: 'df',bind: {
            value: 'clickTime'
        }
    },{
        xtype: 'button',text: 'Click Me!',handler: 'onButtonClick'
    },text: "say hello",handler: "sayHello" //  will call sayHello in viewController
    }]
})

Ext.define('mondernTunes.view.main.MyMainViewController',{
    extend: 'Ext.app.ViewController',alias: 'controller.MyMainViewController',requires: ['Ext.MessageBox'],sayHello: function (button) {
        Ext.MessageBox.alert("hello");
    }
})

问题: 控制台给我一个错误

Uncaught TypeError: Ext.MessageBox.alert is not a function

如何在Ext.MessageBox中获得viewController的实例?

解决方法

尝试使用 Ext.Msg.alert(“ hello”); 代替 Ext.MessageBox.alert(“ hello”);

相关问答

Selenium Web驱动程序和Java。元素在(x,y)点处不可单击。其...
Python-如何使用点“。” 访问字典成员?
Java 字符串是不可变的。到底是什么意思?
Java中的“ final”关键字如何工作?(我仍然可以修改对象。...
“loop:”在Java代码中。这是什么,为什么要编译?
java.lang.ClassNotFoundException:sun.jdbc.odbc.JdbcOdbc...