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.
在学习vue2的过程中遇到了这种问题:
在vue2.0中子组件触发改变值的时候vue组件会报错,例如:
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: "showL"
原因:
组件中不能修改props的值,想修改父组件通过props与子组件通信的数据
解决办法:
将这个父组件传进来的要修改的数据,通过$emit再传回去给父组件,在父组件中进行修改