感谢前端大佬给我写的demo
<template >
<parentA>
<childB v-if="showList1" @switch-tab="switchTab">
child B
</childB>
<childC v-else>
child C
</childC>
</parent>
</template>
<script>
export default {
methods: {
switchTab(val) {
this.showList1 = val;
}
}
}
</script>
<template class="B">
<button @click="handleDisplay"></button>
</template>
<script>
export default {
methods: {
handleDisplay() {
this.$emit('switch-tab', false);
}
}
}
</script>