in parent component, I pass a prop using
.sync to achieve 2-way binding, in child components, I simply bind that prop to a
v-model, in this way, I hope any change in child component can be propagated to parent through this
.sync prop. However, I received the warning:
[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.
Am I doing anything wrong? According to vue document,
.sync is designed by 2-way data binding. How should I do this in child components?