Vue 实现了一套内容分发的 API,这套 API 的设计灵感源自 Web Components 规范草案,将 元素作为承载分发内容的出口。
传值
1. 父->子
## child.vue
<p>
<slot>It's child</slot>
</p>
### parent.vue
<child>It's my child</child>
2. 子->父:传递title
## child.vue
<div>
<slot :title="title">{{title}}</slot>
</div>
## parent.vue vue2版本
<child slot-scope="{ title }">
<template slot-scope="{ title }">
{{ title }}
</template>
</child>
## parent.vue vue3版本
<child>
<template #default="{ title }">
{{ title }}
</template>
</child>