报错 [Vue warn]: Avoid mutating a prop directly since the value will be overwritte

8,819 阅读1分钟

在vue2.0中子组件触发改变值的时候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 value. Prop being mutated: "selectType"

组件内直接修改props的值会报错

解决方法: 在子组件使用该值时需要经过新变量(chooseType)重新传递,这样当这个值变更时,不会造selectType的更改