问题描述
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”);