微信小程序: 插槽的使用
一、无名插槽的使用
1、 新建components文件夹,新建组件hell, hell.wxml中写入:
2、首页中使用hell组件,先在index.wxml中注册hell:

再在index页面中使用:

成功显示如下:

二、具名插槽:指定插槽的位置。
1、 新建components文件夹,新建组件hell, hell.wxml中写入:

2、首页中使用hell组件,先在index.wxml中注册hell:

再在index页面中使用:

此时页面并并不显示“头部”和“底部”,需要我们在hell.js中添加options:{ multipleSlots:true }


浙公网安备 33010602011771号