子組件
<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>