// 子组件
<template>
<view>
<view>组件内部控件</view>
<slot name="body">
<view><text>默认插槽内容</text></view>
</slot>
</view>
</template>
<script setup></script>
<style lang="scss" scoped></style>
// 父组件
<template>
<view>
<unit-component>
<template #body>
<view v-if="show">传入内容</view>
</template>
</unit-component>
</view>
</template>
<script setup>
import { ref } from 'vue';
import unitComponent from './components/unit-component';
const show = ref(false);
</script>
<style lang="scss" scoped></style>
l***@163.com (作者)
游泳,感谢!
2023-12-01 17:46