extjs - 我无法在 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'
}, {
xtype: 'button',
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
in的实例viewController
?
解决方案
试试Ext.Msg.alert("hello"); 而不是Ext.MessageBox.alert("hello");
推荐阅读
- jquery - 如何在 jquery 的 css 路径中添加“或”?
- javascript - 如何读取输入文件、修改其内容并使用 node.js 将结果保存到输出文件?
- http - 如何在go中测试http请求
- matlab - 使用匿名函数 Matlab 的操作
- sql - 无法识别表别名
- javascript - 结合vue和laravel的正确方法
- python - 尝试在 Python 中修改列表
- fosuserbundle - Symfony 4:如何覆盖 Fosuserbundle 验证?
- amazon-web-services - 如何获取当前 VPC 中的子网总数
- python - AttributeError:“dict_values”对象没有属性“更新”