首先 代码按正常的组件传值写的 后来一直报错
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: “showdialog”
说是不能在子组件里修改父组件的值,可是找了好久,没有发现有父组件的值是在子组件里被修改的,于是换个方法,改用ref
父组件
<editDialog
ref="editdialog"
:sectionid="sectionId"
@isReload="isReload"
/>
// 点击触发
edit() {
this.$refs.editdialog.showdialog = true
},
子组件
<el-dialog title="编辑" :visible.sync="showdialog" width="30%">
<el-button @click="cancel">取 消</el-button>
</el-dialog>
data() {
return {
showdialog: false,
}
},
cancel() {
this.showdialog = false
},
以上就可以啦