您好,登錄后才能下訂單哦!
微信小程序 圖片寬度自適應(yīng)的實(shí)現(xiàn)
實(shí)例代碼:
wxml 代碼:
<swiper indicator-dots="{{indicatorDots}}" autoplay="{{autoplay}}" interval="{{interval}}" duration="{{duration}}"> <block wx:for="{{imgUrls}}" wx:key="image"> <swiper-item> <image src="{{item.image}}" model="aspectFit" bindload="imageLoad" /> </swiper-item> </block> </swiper>
JS 代碼:
imageLoad: function () { this.setData({ imageWidth: wx.getSystemInfoSync().windowWidth,//圖片寬度 imgUrls: [ { image: "http://img02.tooopen.com/images/20150928/tooopen_sy_143912755726.jpg" }, { image: "http://img06.tooopen.com/images/20160818/tooopen_sy_175866434296.jpg" }, { image: "http://img06.tooopen.com/images/20160818/tooopen_sy_175833047715.jpg" }], indicatorDots: false,//是否顯示圓點(diǎn) autoplay: true,//自動(dòng)播放 interval: 2000,//間隔時(shí)間 duration: 1000//監(jiān)聽滾動(dòng)和點(diǎn)擊事件 }) }
感謝閱讀,希望能幫助到大家,謝謝大家對(duì)本站的支持!
免責(zé)聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如果涉及侵權(quán)請(qǐng)聯(lián)系站長(zhǎng)郵箱:is@yisu.com進(jìn)行舉報(bào),并提供相關(guān)證據(jù),一經(jīng)查實(shí),將立刻刪除涉嫌侵權(quán)內(nèi)容。