参考网址:https://blog.csdn.net/sllailcp/article/details/78595077
父组件:
1 <template> 2 <div> 3 <el-dialog 4 title="手动登记" 5 :visible.sync="registerVisible" 6 width="60%" 7 @close="CloseReg" 8 > 9 <register v-if="registerVisible" @CancelReg="CancelReg"></register> 10 </el-dialog> 11 </div> 12 </template> 13 14 <script> 15 import register from "@/pages/Register/index.vue"; 16 export default { 17 components: { 18 register: register, 19 }, 20 data() { 21 return { 22 registerVisible: false, 23 }; 24 }, 25 methods: { 26 toRegist() { 27 this.registerVisible = true; 28 }, 29 CancelReg() { 30 this.registerVisible = false; 31 }, 32 }, 33 }; 34 </script>
子组件:
1 this.$emit("CancelReg");--调用父组件函数