报错:[Vue warn]: Avoid mutating a prop directly since the value will be overwritten whenever the paren

时间:2022-01-27 22:00:52

今天在做Vue的时候,子组件关闭的时候,报如下错误

报错:vue.esm.js?65d7:610 [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. Prop being mutated: "isVisible"

问题解决:

父组件里面调用子组件的代码

<NoteBookLimitFlow :isVisible="isShowFlowSearch"></NoteBookLimitFlow>

  

isVisible用来判断是否显示子组件

子组件里面的代码

<el-dialog title="XXXX"
:visible.sync="IsShowPage"
@close="closeForm()">
</el-dialog> watch: {
isVisible(val) {
this.IsShowPage = val;//新增isVisible的watch,监听变更并同步到IsShowPage上
}
}, data() {
return {
//定义一个IsShowPage来接收传递过来的值 
IsShowPage: this.isVisible,
}
}