Vue2项目在封装element-ui的dialog组件时,eslint报错
Unexpected mutation of “dialogVisible” prop.eslintvue/no-mutating-props
大致意思是父组件传递过来的 dialogVisible
属性,不允许在子组件中修改父组件的值
通过 computed
计算属性,将值改变事件抛给父组件
dilogShow: {
get() {
return this.dialogVisible;
},
set(newVal) {
this.$emit("dialogVisibleChange", newVal);
},
},
<--! template部分-->