Android寫過輪播圖的痛楚只有寫過的知道,相對還是比較麻煩的,并沒有一個輪播圖組件,有個ViewPage也需要自己定制,IOS則多用UIScrollerView去實現,這個swiper封裝的相對還是方便的,使用方式也相對那倆容易些。
主要屬性:
屬性只需要設置就行了 也可以抽到js文件的data中進行數據綁定,監聽使用bindchange,在js中做業務處理。
wxml
<!--是否顯示圓點,自動播放, 間隔時間, 監聽滾動和點擊事件--><swiper indicator-dots="true" autoplay="true" duration="1000" bindchange="listenSwiper" ><!--swiper-item只能包含一個節點再多會自動刪除--> <swiper-item> <view style="background: red; height: 150px"></view> </swiper-item> <swiper-item> <view style="background: green; height: 150px"></view> </swiper-item> <swiper-item> <view style="background: blue; height: 150px"></view> </swiper-item> </swiper>
js
Page({ data:{ // text:"這是一個頁面" },/** * 這里處理滾動事件處理 */ listenSwiper:function(e) { //打印信息 console.log(e) }, onLoad:function(options){ // 頁面初始化 options為頁面跳轉所帶來的參數 }, onReady:function(){ // 頁面渲染完成 }, onShow:function(){ // 頁面顯示 }, onHide:function(){ // 頁面隱藏 }, onUnload:function(){ // 頁面關閉 }})
相關文章:
hello WeApp icon組件
Window text組件 switch組件
tabBar底部導航 progress組件 action-sheet
應用生命周期 button組件 modal組件
頁面生命周期 checkbox組件 toast組件
模塊化詳 form組件詳 loading 組件
數據綁定 input 組件 navigator 組件
View組件 picker組件 audio 組件
scroll-view組件 radio組件 video組件
swiper組件 slider組件 Image組件
新聞熱點
疑難解答