前端

vue双向绑定v-model实现子组件修改数据

3212℃

版本说明Vue 2.6.12Vue-Cli 4.2.3需求说明默认情况下,我们可以使用v-model属性来实现父子组件数据双向绑定。这样当父组件数据更新时,子组件的数据也会同步更新。但是如果我们要在子组件更新数据,并且同步更新父组件数据时,就会报错。[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 bas