最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

微信小程序自定義輪播圖

 更新時(shí)間:2018年11月04日 10:25:20   作者:rorntuck7  
這篇文章主要為大家詳細(xì)介紹了微信小程序自定義輪播圖,swiper dots默認(rèn)樣式修改,具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下

本文實(shí)例為大家分享了微信小程序自定義輪播圖展示的具體代碼,供大家參考,具體內(nèi)容如下

默認(rèn)的swiper面板指示點(diǎn)都是小圓點(diǎn)黑灰的,但這滿足不了廣大小伙伴需求,比如其他顏色的,橢圓形的,方形的等等。

首先當(dāng)然是要禁用掉(直接刪掉)swiper屬性indicator-dots,再用view組件模擬dots,對(duì)應(yīng)的代碼如下:

<view class="swiper-container">
 <swiper autoplay="auto" interval="5000" duration="500" current="{{swiperCurrent}}" bindchange="swiperChange" class="swiper">
 <block wx:for="{{slider}}" wx:key="unique">
 <swiper-item>
 <image src="{{item.picUrl}}" class="img"></image>
 </swiper-item>
 </block>
 </swiper>
 
 <view class="dots">
 <block wx:for="{{slider}}" wx:key="unique">
 <view class="dot{{index == swiperCurrent ? ' active' : ''}}"></view>
 </block>
 </view>
</view>

然后是wxss代碼:

swiper-container{
 position: relative;
}
.swiper-container .swiper{
 height: 300rpx;
}
.swiper-container .swiper .img{
 width: 100%;
 height: 100%;
}
.swiper-container .dots{
 position: absolute;
 left: 0;
 right: 0;
 bottom: 20rpx;
 display: flex;
 justify-content: center;
}
.swiper-container .dots .dot{
 margin: 0 8rpx;
 width: 14rpx;
 height: 14rpx;
 background: #fff;
 border-radius: 8rpx;
 transition: all .6s;
}
.swiper-container .dots .dot.active{
 width: 24rpx;
 background: #f80;
}

再對(duì)swiper的bindchange屬性綁定對(duì)應(yīng)的事件:

Page({
data: {
 slider: [
 {picUrl: '../../images/T003R720x288M000000rVobR3xG73f.jpg'},
 {picUrl: '../../images/T003R720x288M000000j6Tax0WLWhD.jpg'},
 {picUrl: '../../images/T003R720x288M000000a4LLK2VXxvj.jpg'},
 ],
 swiperCurrent: 0,
},
swiperChange: function(e){
 this.setData({
 swiperCurrent: e.detail.current
 })
}
})

效果圖:

以上就是本文的全部?jī)?nèi)容,希望對(duì)大家的學(xué)習(xí)有所幫助,也希望大家多多支持腳本之家。

相關(guān)文章

最新評(píng)論

桐梓县| 卓尼县| 邮箱| 嘉义市| 明星| 延川县| 海丰县| 天等县| 永安市| 家居| 陆河县| 资源县| 天柱县| 阳城县| 山阴县| 蚌埠市| 长顺县| 建湖县| 佛学| 漯河市| 平昌县| 徐州市| 紫金县| 宣汉县| 东丰县| 柘城县| 泸水县| 义马市| 威海市| 延安市| 马关县| 武乡县| 凌海市| 阳泉市| 高淳县| 杭锦旗| 兖州市| 高台县| 疏附县| 乌海市| 剑河县|