微信小程序 輪播圖swiper詳解及實(shí)例(源碼下載)
微信小程序 swiper 輪播圖
前言:
1.更新了v0.12的版本后,每次保存都彈出來(lái)一個(gè)打開(kāi)文件窗口。
2.swiper組件的屬性indicator-dots,值為false時(shí),面板指示點(diǎn)還是顯示。要把indicator-dots屬性直接刪掉。
下面進(jìn)入正題:默認(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: 'http://y.gtimg.cn/music/photo_new/T003R720x288M000000rVobR3xG73f.jpg'}, {picUrl: 'http://y.gtimg.cn/music/photo_new/T003R720x288M000000j6Tax0WLWhD.jpg'}, {picUrl: 'http://y.gtimg.cn/music/photo_new/T003R720x288M000000a4LLK2VXxvj.jpg'}, ...... ], swiperCurrent: 0, }, swiperChange: function(e){ this.setData({ swiperCurrent: e.detail.current }) } })
效果預(yù)覽:
項(xiàng)目地址:http://xiazai.jb51.net/201701/yuanma/wx_qqmusic-master(jb51.net).rar
感謝閱讀,希望能幫助到大家,謝謝大家對(duì)本站的支持!
- 微信小程序 swiper組件輪播圖詳解及實(shí)例
- 微信小程序之swiper輪播圖中的圖片自適應(yīng)高度的方法
- 微信小程序視圖容器(swiper)組件創(chuàng)建輪播圖
- 微信小程序使用swiper組件實(shí)現(xiàn)類3D輪播圖
- 微信小程序使用swiper組件實(shí)現(xiàn)層疊輪播圖
- 微信小程序?qū)崿F(xiàn)的3d輪播圖效果示例【基于swiper組件】
- 微信小程序?qū)崿F(xiàn)Swiper輪播圖效果
- 微信小程序輪播圖swiper代碼詳解
- 微信小程序非swiper組件實(shí)現(xiàn)的自定義偽3D輪播圖效果示例
- 微信小程序swiper輪播圖組件使用方法詳解
相關(guān)文章
微信小程序 input輸入框控件詳解及實(shí)例(多種示例)
這篇文章主要介紹了微信小程序 input輸入框控件詳解及實(shí)例(多種示例)的相關(guān)資料,輸入框在程序中是最常見(jiàn)的,登錄,注冊(cè),獲取搜索框中的內(nèi)容等等都需要,需要的朋友可以參考下2016-12-12JavaScript實(shí)現(xiàn)優(yōu)先級(jí)隊(duì)列
這篇文章主要介紹了JavaScript如何實(shí)現(xiàn)優(yōu)先級(jí)隊(duì)列,在計(jì)算機(jī)里,隊(duì)列是一種先進(jìn)先出的數(shù)據(jù)結(jié)構(gòu)。就跟我們平時(shí)排隊(duì)一樣,先到的排在前面,前面的優(yōu)先處理,下面我們就來(lái)看看在JavaScript里面的優(yōu)先隊(duì)列又當(dāng)如何2021-12-12JavaScript中Map與Object應(yīng)用場(chǎng)景
這篇文章主要為大家介紹了JavaScript中Map與Object應(yīng)用場(chǎng)景的示例詳解,有需要的朋友可以借鑒參考下,希望能夠有所幫助,祝大家多多進(jìn)步,早日升職加薪2022-07-07微信小程序 使用騰訊地圖SDK詳解及實(shí)現(xiàn)步驟
這篇文章主要介紹了微信小程序 使用騰訊地圖SDK詳解及實(shí)現(xiàn)步驟的相關(guān)資料,需要的朋友可以參考下2017-02-02