父组件
<template>
<ex-record v-show="isShow == '1'" @record="show"></ex-record>
<div v-show="isShow == '0'">
<el-button type="primary" @click="Record ()">切换子组件</el-button>
</div>
</template>
<script lang="ts" setup>
import exRecord from './ex-record.vue';
const isShow = ref('0');
const Record = () => {
isShow.value = '1';
};
const show= () => {
isShow.value = '0';
};
</script>
子组件
<template>
<el-button link type="primary" @click="goBack()">返回</el-button>
</template>
<script lang="ts" setup>
const emit = defineEmits(['record']);
const goBack = () => {
emit('record');
};
</script>```
vue3组合式组件切换
最新推荐文章于 2024-03-18 21:55:03 发布