我试图使它在煎茶小提琴中工作。如果运行它,我会在控制台日志“ Uncaught TypeError:controller.setView is a function”中看到此错误。仅当我从视图中删除控制器声明时,它才有效。我究竟做错了什么?
Ext.define('MyApp.controller.Whatever', {
extend: 'Ext.app.Controller',
alias: 'controller.Whatever',
init: function() {
alert("Yes!");
}
});
Ext.define('MyApp.view.Whatever', {
extend: 'Ext.form.Panel',
controller: 'Whatever',
title: 'Hello',
width: 200,
html: '<p>World!</p>',
renderTo: Ext.getBody()
});
Ext.application({
name: 'MyApp',
launch: function() {
Ext.create('MyApp.view.Whatever');
}
});
根据下面的答案,这个工作
Ext.define('MyApp.controller.Whatever', {
extend: 'Ext.app.ViewController',
alias: 'controller.Whatever',
init: function() {
alert("Yes!");
}
});
Ext.define('MyApp.view.Whatever', {
extend: 'Ext.form.Panel',
alias:'widget.Whatever',
controller: 'Whatever',
title: 'Hello',
width: 200,
html: '<p>World!</p>',
renderTo: Ext.getBody()
});
Ext.application({
name: 'MyApp',
launch: function() {
Ext.create('MyApp.view.Whatever');
}
});
我认为您使用的是Ext JS 5或更高版本,请使用此功能。
Ext.app.ViewController而不是Ext.app.Controller。
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句