這篇文章給大家分享的是有關圖片輪播組件gallery slider怎么用的內容。小編覺得挺實用的,因此分享給大家做個參考,一起跟隨小編過來看看吧。
先上效果圖:
wxml
<scroll-view scroll-y="true" style="height:200px" class="page-body" bindscrolltolower="loadMore"> <view class="swiper"> <swiper class="swiper-box" indicator-dots="{{indicatorDots}}" vertical="{{vertical}}" autoplay="{{autoplay}}" interval="{{interval}}" duration="{{duration}}" indicator-color="#fff" indicator-active-color="red"> <block wx:for-items="{{banner_url}}" wx:key="item.id"> <navigator url="../blogList/blogList"> <swiper-item> <block wx:if="{{item}}"> <image class="imgw" src="{{item.url}}" mode="aspectFill"/> </block> <block wx:else> <image src="../../images/default_pic.png" mode="aspectFill"></image> </block> </swiper-item> </navigator> </block> </swiper> </view> </scroll-view>
wxss
.imgw{width:100%;}
js
/** *頁面的初始數據 */ data: { banner_url: data.bannerList(), open: false, indicatorDots: true,//是否顯示面板指示點 autoplay: true,//是否開啟自動切換 interval: 3000,//自動切換時間間隔 duration: 500//滑動動畫時長 }
最終效果:
總結:
1. scroll-view組件的作用是可以觸發觸摸滑動
2. swiper組件的作用是制作圖片自動切換,形成輪播
3. navigator組件的作用是給每個圖片添加鏈接
主要是scroll-view和swiper兩個組件制作成可滑動的輪播組件。
感謝各位的閱讀!關于“圖片輪播組件gallery slider怎么用”這篇文章就分享到這里了,希望以上內容可以對大家有一定的幫助,讓大家可以學到更多知識,如果覺得文章不錯,可以把它分享出去讓更多的人看到吧!
免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。