微信小程序swiper高度自適應(yīng)的實現(xiàn)方式,首先swiper默認最小高度150,下面請看開發(fā)實例。
要求:swiper高度自適應(yīng)
wxml
<view class='swiper'> <swiper indicator-dots="{{indicatorDots}}" vertical="{{vertical}}" autoplay="{{autoplay}}" duration="{{duration}}" interval='{{interval}}' bindchange="bindchange" circular="{{circular}}" style="height:{{imgheights[current]}}rpx;"> <block wx:for='{{imgList}}' wx:key="{{index}}"> <swiper-item> <image src="{{item}}" data-id='{{index}}' class="slide-image" mode="widthFix" bindload="imageLoad"/> </swiper-item> </block> </swiper> </view>
wxss
.swiper image { width: 100%; height: auto; }
wxjs
data: { //圖片地址 imgList: ['/images/wyh-img_bg.png', '/images/wyh-img8.png', '/images/wyh-img_shop1.png', '/images/wyh-img_bg1.png'], //是否采用銜接滑動 circular: true, //是否顯示畫板指示點 indicatorDots: false, //選中點的顏色 indicatorcolor: "#000", //是否豎直 vertical: false, //是否自動切換 autoplay: true, //自動切換的間隔 interval: 2500, //滑動動畫時長毫秒 duration: 100, //所有圖片的高度 (必須) imgheights: [], //圖片寬度 imgwidth: 750, //默認 (必須) current: 0 }, imageLoad: function (e) {//獲取圖片真實寬度 var imgwidth = e.detail.width, imgheight = e.detail.height, //寬高比 ratio = imgwidth / imgheight; console.log(imgwidth, imgheight) //計算的高度值 var viewHeight = 750 / ratio; var imgheight = viewHeight; var imgheights = this.data.imgheights; //把每一張圖片的對應(yīng)的高度記錄到數(shù)組里 imgheights[e.target.dataset.id] = imgheight; this.setData({ imgheights: imgheights }) }, bindchange: function (e) { // console.log(e.detail.current) this.setData({ current: e.detail.current }) },
KESION 科汛軟件
KESION 科汛軟件是國內(nèi)領(lǐng)先的在線教育軟件及私域社交電商軟件服務(wù)提供商,長期專注于為企業(yè)提供在線教育軟件及社交電商SaaS平臺解決方案。
公司核心產(chǎn)品云開店SaaS社交電商服務(wù)平臺、在線教育SaaS服務(wù)平臺、教育企業(yè)數(shù)字化SaaS云平臺、企微營銷助手、私有化獨立部署品牌網(wǎng)校和在線教育咨詢等。KESION 不斷通過技術(shù)創(chuàng)新,提供產(chǎn)品和服務(wù),助力企業(yè)向數(shù)字化轉(zhuǎn)型,通過科技驅(qū)動商業(yè)革新,讓商業(yè)變得更智慧!
一般小程序語音格式是mp3,那么如何將語音格式mp3轉(zhuǎn)換為文字,下面為大家介紹微信小程序語音轉(zhuǎn)文字的實現(xiàn)方式...
拼多多的火爆大多來自于它的拼團,以及裂變營銷,那么下面小編為大家介紹拼多多小程序商城系統(tǒng)開發(fā)。...