最新国产好看的视频,伊人天堂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,對應(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;
}

再對swiper的bindchange屬性綁定對應(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
 })
}
})

效果圖:

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

相關(guān)文章

最新評論

乌兰浩特市| 体育| 当雄县| 龙南县| 叙永县| 怀安县| 通许县| 石楼县| 贵定县| 洪湖市| 安岳县| 肥西县| 大城县| 东兴市| 维西| 中山市| 静宁县| 山东省| 侯马市| 盈江县| 翁源县| 永靖县| 集安市| 连江县| 益阳市| 抚顺市| 金溪县| 根河市| 建德市| 沁阳市| 修文县| 衢州市| 扬中市| 宣恩县| 房产| 蒙自县| 尚志市| 拉萨市| 柳河县| 南阳市| 广南县|