18:slot多插槽

创建pages/component/getmanyslot/getmanyslot

getmanyslot.js:

Component({
//组件的方法列表
  options:{
    multipleSlots:true
  }
})

getmanyslot.json:

{
  "component":true,
  "usingComponents": {}
}

getmanyslot.wxml:

<!--pages/component/getmanyslot/getmanyslot.wxml-->
<view>我是多个组件的开始</view>
<view class="slot1"><slot name="slot1"/></view>
<view class="slot2"><slot name="slot2"/></view>
<view class="slot3"><slot name="slot3"/></view>
<view>我是多个组件的结束</view>

test.json:

"usingComponents": {
    "get-manyslot":"/pages/component/getmanyslot/getmanyslot"
  }

test.wxml:

<get-manyslot>
   <slider slot="slot2"/>
   <button size="mini" slot="slot1">我是插入多个插槽的按钮</button>
   <text slot="slot3">我是slot3哈哈哈哈哈哈</text>
</get-manyslot>

test.wxml中注意:
1:多个插槽时给每个插槽起个名字,而且test.wxml中slot中写getmanyslot.wxml中的slot标签中name。
2:必须在getmanyslot.js 中Component对象中添加一个选项:options multipleSlots:true。
3:这里展示顺序取决于getmanyslot.wxml中view从上到下的顺序。

效果:
在这里插入图片描述

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值