javascript 未捕获的类型错误:无法使用 Sencha 读取未定义的属性“应用”
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/23118185/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Uncaught TypeError: Cannot read property 'apply' of undefined with Sencha
提问by agorjux
I have some problems with sencha touch. I have this simple code :
我对sencha touch 有一些问题。我有这个简单的代码:
items: [
{
name: "horo",
xtype: 'togglefield',
label: 'Horodateur ?',
labelWidth: '55%',
disabled: false,
listeners: {
beforechange: function (slider, thumb, newValue, oldValue) {
if (oldValue == 0 && newValue == 1) {
alert("toto");
}
},
change: function (slider, thumb, newValue, oldValue) {
if (oldValue == 0 && newValue == 1) {
alert("titi");
}
else if (oldValue == 1 && newValue == 0)
alert("tata");
}
}
},
And I have this error on my console :
我的控制台上有这个错误:
Uncaught TypeError: Cannot read property 'apply' of undefined.
未捕获的类型错误:无法读取未定义的属性“应用”。
What's the problem ?
My console say something else, maybe the Controller.js
is the problem.
有什么问题 ?我的控制台说别的,也许Controller.js
是问题所在。
回答by Ilan M
I had the same problem. This problem can occur when you define some listeners and you did not define the function in your controller. I can see that beforechange and change have functions so maybe there are more items in your code that you have not shown here in the forum. If there are listeners and the listener referer to a function that do not exist then you will get an error. "Uncaught TypeError: Cannot read property 'apply' of undefined"
我有同样的问题。当您定义了一些侦听器而您没有在控制器中定义函数时,就会出现此问题。我可以看到 beforechange 和 change 有函数,所以也许你的代码中有更多你没有在论坛中显示的项目。如果有侦听器和侦听器引用不存在的函数,那么您将收到错误消息。“未捕获的类型错误:无法读取未定义的属性‘应用’”