插槽<slot>相当于是占位符 留给组件使用者使用
一、默认只支持单个插槽
1、例如声明一个组件
<view>
<view>这里是组件的内部结构</view>
<slot></slot>
<view>组件结束</view>
</view>
2、引入此组件
"usingComponents": {
"my-test4": "/components/test4/test4"
},
3、使用时
<my-test4>
<text>插槽的位置</text>
</my-test4>
二、启用多个插槽
1、在组件的js文件中与properties平级的位置写入
options: {
multipleSlots: true
},
2、创建多个插槽时使用name属性区分
<view>
<view>这里是组件的内部结构</view>
<slot name="before"></slot>
<slot name="after"></slot>
<view>组件结束</view>
</view>
3、使用时加入slot属性,值为声明插槽时指定的name值
<my-test4>
<text slot="before">插槽的位置before</text>
<text slot="after">插槽的位置after</text>
</my-test4>