[Vue warn]: Avoid mutating a prop directly since the value will be overwritten whenever the parent..

 错误:[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: "value".

Translation: [Vue Warning]: Avoid mutating props directly, as the value will be overwritten whenever the parent component re-renders. Instead, data or computed properties based on the prop value should be used. prop mutated: "value". Simply put, you cannot directly modify the property values ​​received by props.

Solution: You only need to redefine a variable in the data() of the child component, assign the props attribute to the newly defined variable of the child component, and use the attribute .sync to update the data synchronously to the parent component

The original way of writing:

parent component

Subassembly

After modification, the parent component remains unchanged, and the child component:

 

Guess you like

Origin blog.csdn.net/qq_58062502/article/details/128902886