【发布时间】:2018-02-11 05:13:46
【问题描述】:
能否请您告诉我如何在 vue js 中使用 watch 功能。我尝试使用但出现此错误。
vue.js:485 [Vue warn]: Avoid mutating a prop directly since the value will be overwritten whenever the parent component re-renders. Instead, use a data or computed property based on the prop's value. Prop being mutated: "m"
found in
---> <AddTodo>
<Root>
https://plnkr.co/edit/hVQKk3Wl9DF3aNx0hs88?p=preview
我在主组件中创建了不同的组件和watch属性
var AddTODO = Vue.extend({
template: '#add-todo',
props: ['m'],
data: function () {
return {
message: ''
}
},
methods: {
addTodo: function () {
console.log(this.message)
console.log(this.m);
this.m =this.message;
},
},
});
当我尝试添加 item 时,我收到了这个错误。
重现此错误的步骤
- 在输入字段中输入任何内容并单击
Add button
【问题讨论】:
-
无法复制,工作正常
标签: javascript vue.js vuejs2 vue-component vue-router