其他分享
首页 > 其他分享> > vue3项目中报错:Unexpected mutation of "xxx" prop

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

标签:Unexpected,父级,xxx,prop,报错,mutation,dialogVisible,vue3
来源: https://www.cnblogs.com/rainbow70626/p/16459975.html