此为个人总结,断章取义,不可用于参考。
借用师父的一句话,是为了解决功能模块中结构的问题。
<slot>
在vue的官网上被称为内容分发。但是其实叫做插槽更为贴切。
此目的为了使得能够在父组件中的子组件中加入拓展的功能。而在子组件则要留出位置以备后用,<slot>
就是这个留出来的位置或者插槽。
在父组件中
<template>
<child-component>
<div>随意插入的数据</div>
<div slot="chaCard">随意插入的数据</div>
</child-component>
</template>
在<child-component>
子组件中
<template>
<slot></slot>
<slot name="chaCard">具名</slot>
</template>