0
我有这个成分在我vue.js应用:Vue道具变为空?
export default {
props: ['forums'],
methods: {
increment(forum, index) {
ForumService.increment(forum)
.then(() => {
this.forums.splice(index -1, 2, this.forums[index], this.forums[index -1]);
});
},
}
}
但是当我尝试递增:
<i class="material-icons" @click="increment(forum)"></i>
的道具forums
变成空(我可以看到,在我的VUE devtools )。我怎样才能解决这个问题?
不应该直接变异一个'prop',而不是你应该创建一个本地副本和祭坛来代替。此外,你似乎没有通过'索引'。 –
@craig_h感谢您的回复。你能举个例子吗? (我已经添加了索引谢谢) – Jamie