在子组件HelloWorld.vue中:
<template>
<div class="hello">
111111
</div>
</template>
<script lang="ts">
import { Options, Vue } from 'vue-class-component';
@Options({
props: {
msg: String
}
})
export default class HelloWorld extends Vue {
msg!: string
}
</script>
<!-- Add "scoped" attribute to limit CSS to this component only -->
<style scoped lang="less">
</style>
在父组件中HomeView.vue:
<template>
<div>
<!-- slot插槽 -->
<slot>11111</slot>
<HelloWorld />
222
</div>
</template>
<script lang="ts" setup>
import HelloWorld from '@/components/HelloWorld.vue';
import {ref} from 'vue';
</script>