微信小程序 圖片寬度自適應(yīng)的實(shí)現(xiàn)
微信小程序 圖片寬度自適應(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" style="width: {{imageWidth}}px;" 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ì)本站的支持!
相關(guān)文章
Skypack布局前端基建實(shí)現(xiàn)過程詳解
這篇文章主要為大家介紹了Skypack布局前端基建過程詳解,有需要的朋友可以借鑒參考下,希望能夠有所幫助,祝大家多多進(jìn)步,早日升職加薪2022-07-07Dom-api MutationObserver使用方法詳解
這篇文章主要為大家介紹了Dom-api MutationObserver使用方法詳解,有需要的朋友可以借鑒參考下,希望能夠有所幫助,祝大家多多進(jìn)步,早日升職加薪2022-11-11Server-sent?events實(shí)時(shí)獲取服務(wù)端數(shù)據(jù)技術(shù)詳解
這篇文章主要為大家介紹了Server-sent?events實(shí)時(shí)獲取服務(wù)端數(shù)據(jù)技術(shù)詳解,有需要的朋友可以借鑒參考下,希望能夠有所幫助,祝大家多多進(jìn)步,早日升職加薪2023-02-02在JavaScript實(shí)例對(duì)象中改寫原型方法詳情
這篇文章主要介紹了在JavaScript實(shí)例對(duì)象中改寫原型方法的一下相關(guān)資料,需要的效果版可以參考一下文章詳細(xì)內(nèi)容,希望對(duì)你有所幫助2021-10-10JavaScript?sort方法實(shí)現(xiàn)數(shù)組升序降序
這篇文章主要為大家介紹了JavaScript?sort方法實(shí)現(xiàn)數(shù)組升序降序示例詳解,有需要的朋友可以借鑒參考下,希望能夠有所幫助,祝大家多多進(jìn)步,早日升職加薪2023-07-07詳解JavaScript中數(shù)組的相關(guān)知識(shí)
這篇文章主要介紹了JavaScript中中數(shù)組的相關(guān)知識(shí),是JS入門學(xué)習(xí)中的基礎(chǔ)知識(shí),需要的朋友可以參考下2015-07-07fabric.js圖層功能獨(dú)立顯隱?添加?刪除?預(yù)覽實(shí)現(xiàn)詳解
這篇文章主要為大家介紹了fabric.js圖層功能獨(dú)立顯隱?添加?刪除?預(yù)覽實(shí)現(xiàn)詳解,有需要的朋友可以借鑒參考下,希望能夠有所幫助,祝大家多多進(jìn)步,早日升職加薪2023-05-05