![](/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.