目录
1、默认插槽
2、具名插槽
3、作用域插槽
1、默认插槽
父组件中:
<category>
<div>hello</div>
</category>
子组件中:
<template>
<div>
<slot></slot>
</div>
</template>
2、具名插槽
![](https://i-blog.csdnimg.cn/blog_migrate/6c8c89a1f5a04cc9ed11858d537e9b30.png)
template可以包裹元素
父组件中可以有两种写法:
第一种:slot="footer"
第二种:v-slot:footer(这种形式只能用在template里边)
3、作用域插槽
![](https://i-blog.csdnimg.cn/blog_migrate/d39a055ce20d506b33a1adac6e89b9ae.png)
父组件:
![](https://i-blog.csdnimg.cn/blog_migrate/76223e6131eafc74160c3f91ef709143.png)
子组件: (games数据在子组件内)
![](https://i-blog.csdnimg.cn/blog_migrate/9520b93d8c5ba398f9ac4121ed0cfe90.png)