【发布时间】:2018-05-26 08:06:07
【问题描述】:
我有一个类似的东西:
new Vue({
el: '#core',
data: {
checkedThemes: []
...
}
})
之后:
mounted() {
...
var theme = parseInt(parameters['theme']);
this.checkedThemes.push(theme);
...
}
调用推送会引发 TypeError: Cannot read property 'name' of undefined 但是当我从网页执行此操作(添加一些值)时,它可以工作。
编辑:此错误出现在 Chrome 中。在 Firefox 中,我得到:[Vue 警告]:渲染错误:“TypeError:主题 [checkedTheme] 未定义”
此外,推送后数组被很好地填充。
这个错误是从哪里来的?
【问题讨论】:
-
清楚地检查您的日志,它会指向您的来源
-
推送调用,然后它进入一些 vue.js 内部代码
-
好吧,您至少需要分享日志的屏幕截图,因为我在您的代码中看不到
name -
首先,我在你的
data()中没有看到checkedThemes,接下来,parameters是从哪里来的? -
另外,您在 Chrome 中的错误非常具体:
themes[checkedTheme] is undefined
标签: javascript vue.js