vue3项目中报错:Unexpected mutation of "xxx" prop

vue3 中element 弹窗绑定需要通过v-model,这个时候父级会传个dialogVisible(boolean值)过来,结果会报eslint的错。
Unexpected mutation of "dialogVisible" prop,大概就是说不允许在子级修改父级的数据。
问题描述:
<el-dialog :title="title" width="800px" v-model="dialogVisible" destroy-on-close @close="closeCallback">

解决办法;

 const dialogShow = computed({
      get: () => props.dialogVisible,
      set: val => context.emit('update:dialogVisible', val)
  })
 <el-dialog :title="title" width="800px" v-model="dialogShow" destroy-on-close @close="closeCallback">

 

原文链接:Unexpected mutation of "dialogVisible" prop

参考链接:

1、Unexpected mutation of “XXXX“ prop

2、Vue.js : Unexpected mutation of "quantity" prop

posted @ 2022-07-09 00:09  rainbow70626  阅读(9901)  评论(0编辑  收藏  举报