插槽的理解:
子组件中提供给父组件使用的一共占位符,<slot></slot>表示,所以,插槽一般是使用在子组件中的。
插槽分为匿名插槽、具名插槽、作用域插槽三种。
匿名插槽
在子组件中写一个<slot></slot>占位,父组件中,调用子组件就可以了
子组件children.vue:
<template>
<div class="box">
<div class="text_slot">
<p class="title">匿名插槽</p>
<slot>我是默认信息</slot>
</div>
</div>
</template>
父组件father.vue
<template>
<div class="box">
<childern >
<p >我是在匿名插槽1</p>
<p >我是在匿名插槽2