vue报错 [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

时间:2022-01-27 22:00:46

[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: 'mode'

这个错误是我在子组件里操作父组件传过来的值时报的错,看了官方文档说要保证父子组件单向数据流,子组件不允许修改父组件的值,但是数组对象可以

如果要修改可以通过$emit触发父组件里的方法去修改

如果你只是在子组件里体现,可以用个新的key去接收然后再修改新的key