1.App.vue
<template>
<div>
<test><template v-slot:test><div>我是测试</div></template></test>
</div>
<router-view/>
</template>
<script>
import Test from "./components/tabbar/test";
export default {
components: {
Test,
}
}
</script>
<style>
</style>
2.test.vue
<template>
<div id="test">
<slot name="test"></slot>
</div>
</template>
<script>
export default {
name: "test"
}
</script>
<style scoped>
#test div{
background-color: red;
height: 50px;
width: 50px;
}
</style>