![](/img/trans.png)
[英]Uncaught TypeError: controller.setView is not a function in EXTJS
[英]EXTjs: Uncaught TypeError: controller.setView is not a function
我试图使它在煎茶小提琴中工作。 如果运行它,我会在控制台日志“ 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。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.