[Vuejs]-How to specify types, default values and validators for Vue component data

0👍

[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: “editing”

I see. You’re passing the prop editing from the parent component to the child component. Then, in the child component, you use that prop and definitely have a method that mutate that prop editing directly.

They said you should use a computed value which derived on the prop editing and mutate that computed value instead.

In addition, whenever you want to change the value of the prop editing, you should emit an event and let the parent component listen to that, then mutate the editing value. After the editing value is changed, the child component will automatically reflect the change.

Leave a comment