微信小程使用swiper組件實現(xiàn)圖片輪播切換顯示功能【附源碼下載】
更新時間:2017年12月12日 10:01:08 作者:FutrueJet
這篇文章主要介紹了微信小程使用swiper組件實現(xiàn)圖片輪播切換顯示功能,涉及swiper組件相關(guān)屬性使用技巧,并附帶源碼供讀者下載參考,需要的朋友可以參考下
本文實例講述了微信小程使用swiper組件實現(xiàn)圖片輪播切換顯示功能。分享給大家供大家參考,具體如下:
1、效果展示
2、關(guān)鍵代碼
index.wxml:
<swiper indicator-dots="true"autoplay="true" interval="3000" duration="600" style="height:300px;"> <swiper-item> <image src="../../pages/images/img1.png" style="display: block;height: 300px;"/> </swiper-item> <swiper-item> <image src="../../pages/images/img2.png" style="display: block;height: 300px;"/> </swiper-item> <swiper-item> <image src="../../pages/images/img3.png" style="display: block;height: 300px;"/> </swiper-item> </swiper>
swiper組件屬性說明如下:
屬性名 | 類型 | 默認值 | 說明 | 最低版本 |
---|---|---|---|---|
indicator-dots | Boolean | false | 是否顯示面板指示點 | |
indicator-color | Color | rgba(0, 0, 0, .3) | 指示點顏色 | 1.1.0 |
indicator-active-color | Color | #000000 | 當前選中的指示點顏色 | 1.1.0 |
autoplay | Boolean | false | 是否自動切換 | |
current | Number | 0 | 當前所在頁面的 index | |
interval | Number | 5000 | 自動切換時間間隔 | |
duration | Number | 500 | 滑動動畫時長 | |
circular | Boolean | false | 是否采用銜接滑動 | |
vertical | Boolean | false | 滑動方向是否為縱向 | |
bindchange | EventHandle | current 改變時會觸發(fā) change 事件,event.detail = {current: current, source: source} |
3、源代碼點擊此處本站下載。
關(guān)于swiper詳細說明還可參考官方文檔:https://mp.weixin.qq.com/debug/wxadoc/dev/component/swiper.html
希望本文所述對大家微信小程序開發(fā)有所幫助。
相關(guān)文章
js實現(xiàn)數(shù)據(jù)雙向綁定(訪問器監(jiān)聽)
這篇文章主要為大家詳細介紹了采用訪問器監(jiān)聽的方式實現(xiàn)簡單數(shù)據(jù)雙向綁定,文中示例代碼介紹的非常詳細,具有一定的參考價值,感興趣的小伙伴們可以參考一下2021-09-09window.event快達到全瀏覽器支持了,以后使用就方便了
在Tangram群里討論到<a href="#" onclick="baidu.event.preventDefault(event);">的寫法時,以為標準瀏覽器只能用arguments[0]來獲取到event,結(jié)果nodiseal同學說已經(jīng)可以這么用了,于是做了以下測試2011-11-11