子组件
<template><el-dialog title="新增部门" :visible="showDialog" @close="close"> </el-dialog>
</template>
<script>
export default {props: {showDialog: {type: Boolean,default: false,},},data() {return {};},methods: {close() {this.$emit("update:showDialog", false);},},
};
</script>
父组件
表示会接收子组件的事件 undate:showDialog,值=>属性 .sync可以监听到,会把传过来的值赋给前面的属性showDialog
<addDept :showDialog.sync="showDialog"></addDept>