vue报 Avoid mutating a prop directly since the value will be overwritten whenever the parent

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: “tableNmae”

大概意思是:避免直接改变属性,因为每当父组件重新渲染时,该值将被覆盖。相反,使用基于属性值的数据或计算属性。通过props传递给子组件的tableNmae,不能在子组件内部修改props中的tableNmae值。

v-model通常用于input的双向数据绑定 ,也可以实现子组件到父组件数据的双向数据绑定

:model是v-bind:model的缩写

这种只是将父组件的数据传递到了子组件,并没有实现子组件和父组件数据的双向绑定。

引用类型除外,子组件改变引用类型的数据的话,父组件也会改变。

猜你喜欢

转载自blog.csdn.net/god_sword_/article/details/129291411