2022-09-23 Avoid mutating a prop directly since the value will be overwritten whenever the parent component re-renders.
父组件给子组件传值,提示子组件不能直接修改父组件传递过来的值,完整报错:
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: "value"
解释:避免直接更改props,因为每当父组件重新渲染时,该值都会被覆盖。而是使用基于props值的数据或计算属性。正在修改的属性:“value”
解决方案:把子组件要修改的值通过$emit返回给父组件,让后者去修改。
this.$emit('value', nValue)