本文實(shí)例講述了微信小程序實(shí)現(xiàn)圖片滾動(dòng)效果。分享給大家供大家參考,具體如下:
效果:左右滑動(dòng)可以切換展示圖片
代碼:
<!--pages/test/test.wxml--><!-- 組件 --><swiper> <swiper-item wx:for="{{imgUrls}}"> <image src='{{item}}' width="335" height="150" mode='widthFix' class='img' /> </swiper-item></swiper>
pages/test/test.js:
Page({ data: { imgUrls:[ 'https://gss0.baidu.com/9fo3dSag_xI4khGko9WTAnF6hhy/zhidao/wh%3D600%2C800/sign=8b20fba45e6034a829b7b087fb23656c/14ce36d3d539b60028f67d12eb50352ac65cb75e.jpg', 'https://gss0.baidu.com/9vo3dSag_xI4khGko9WTAnF6hhy/zhidao/wh%3D600%2C800/sign=3386e39a49fbfbeddc0c3e7948c0db0e/32fa828ba61ea8d3943606a1950a304e251f587a.jpg', 'http://img04.sogoucdn.com/app/a/100520093/ca86e620b9e623ff-d72d635343d5bade-dcf2acda7a45cb44f172db138bdf8d2d.jpg', ] }, //事件處理函數(shù) toupper:function(){ console.log("觸發(fā)了toupper"); }})
pages/test/test.wxss:
.img{ width: 100%;}
運(yùn)行結(jié)果:
心得:
autoplay=”true”
希望本文所述對(duì)大家微信小程序開發(fā)有所幫助。
新聞熱點(diǎn)
疑難解答
圖片精選