微信小程序 swiper 自定义组件

实现功能

  1.  点击tab 轮播跟这改变
  2.  切换轮播 tab选中值相应改变
  3.  轮播内容 按照内容高度自适应 (默认150px)
  4.  slot功能  自定义每一个轮播的内容   

使用方法

<myswiper currentTab='{{currentTab}}' swiperList="{{itemList}}"  TabList="{{TabList}}" bindtabListChange="tabListChange" bindswiperListChange="swiperListChange">
    <view slot="list0" wx:if="{{currentTab==0}}" class="swiper_list_item">
    </view>
    <view slot="list1" wx:if="{{currentTab==1}}" class="swiper_list_item">
    </view>
    <view slot="list2" wx:if="{{currentTab==2}}" class="swiper_list_item">
    </view>
    <view slot="list3" wx:if="{{currentTab==3}}" class="swiper_list_item">
    </view>
</myswiper>

属性解释

  1.  currentTab :当前选中的tab  string
  2.  swiperList : 需要渲染多少个轮播  数组  貌似改成数字更合适
  3.  TabList :tab切换的时候 渲染的数据  (传空不展示)
  4.  tabListChange : 点击tab事件  返回值为点击的当前数据的所有值加点击下标
  5. swiperListChange : 切换轮播回调事件   返回值 滑动后的下标
  6. name slot 自定义展示内容用到  不允许修改
  7. class 获取高度用到  不允许修改
  8. wx:if  因为if  所以高度取得是第一个 swiper_list_item 的高  (只会出现一个)

百度网盘链接

链接: https://pan.baidu.com/s/1fAtp6K-eBe5XVD5suM7bBw  

提取码: rdnc

永久有效

  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值