微信小程使用swiper組件實(shí)現(xiàn)圖片輪播切換顯示功能【附源碼下載】
本文實(shí)例講述了微信小程使用swiper組件實(shí)現(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組件屬性說明如下:
屬性名 | 類型 | 默認(rèn)值 | 說明 | 最低版本 |
---|---|---|---|---|
indicator-dots | Boolean | false | 是否顯示面板指示點(diǎn) | |
indicator-color | Color | rgba(0, 0, 0, .3) | 指示點(diǎn)顏色 | 1.1.0 |
indicator-active-color | Color | #000000 | 當(dāng)前選中的指示點(diǎn)顏色 | 1.1.0 |
autoplay | Boolean | false | 是否自動(dòng)切換 | |
current | Number | 0 | 當(dāng)前所在頁面的 index | |
interval | Number | 5000 | 自動(dòng)切換時(shí)間間隔 | |
duration | Number | 500 | 滑動(dòng)動(dòng)畫時(shí)長(zhǎng) | |
circular | Boolean | false | 是否采用銜接滑動(dòng) | |
vertical | Boolean | false | 滑動(dòng)方向是否為縱向 | |
bindchange | EventHandle | current 改變時(shí)會(huì)觸發(fā) change 事件,event.detail = {current: current, source: source} |
3、源代碼點(diǎn)擊此處本站下載。
關(guān)于swiper詳細(xì)說明還可參考官方文檔:https://mp.weixin.qq.com/debug/wxadoc/dev/component/swiper.html
希望本文所述對(duì)大家微信小程序開發(fā)有所幫助。
相關(guān)文章
原生js仿jquery實(shí)現(xiàn)對(duì)Ajax的封裝
大家都知道jquery在我們?nèi)粘i_發(fā)中的使用頻率非常高,但jquery說到底還是對(duì)js的封裝,我們不能光會(huì)使用,只有知道了其中的遠(yuǎn)離才能更好的使用,所以這篇文章主要介紹的是原生js仿jquery實(shí)現(xiàn)對(duì)Ajax封裝的方法。2016-10-10JS實(shí)現(xiàn)即點(diǎn)即編輯功能代碼
以前在網(wǎng)上都看到過類似的功能,不過沒自己想要實(shí)現(xiàn)過,這次剛好做靜態(tài)頁面中有這樣的一個(gè)需求,就試著自己做做看,做完發(fā)現(xiàn)也不是什么很難的事情。2008-10-10js實(shí)現(xiàn)數(shù)據(jù)雙向綁定(訪問器監(jiān)聽)
這篇文章主要為大家詳細(xì)介紹了采用訪問器監(jiān)聽的方式實(shí)現(xiàn)簡(jiǎn)單數(shù)據(jù)雙向綁定,文中示例代碼介紹的非常詳細(xì),具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下2021-09-09window.event快達(dá)到全瀏覽器支持了,以后使用就方便了
在Tangram群里討論到<a href="#" onclick="baidu.event.preventDefault(event);">的寫法時(shí),以為標(biāo)準(zhǔn)瀏覽器只能用arguments[0]來獲取到event,結(jié)果nodiseal同學(xué)說已經(jīng)可以這么用了,于是做了以下測(cè)試2011-11-11