国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 熱點 > 微信 > 正文

微信小程序實現banner圖輪播效果

2024-07-22 01:19:05
字體:
來源:轉載
供稿:網友

本文實例為大家分享了微信小程序實現banner圖輪播的具體代碼,供大家參考,具體內容如下

效果圖:

indicator-active-color="#007aff"http://修改選中圖片圓點的顏色

js:

const app = getApp() Page({ data: { //-----------模擬banner圖----------- imgUrls: [ '/image/1545118381903.jpg', '/image/1545118566631.jpg' ], circular: true, //是否顯示畫板指示點  indicatorDots: true, //選中點的顏色  //是否豎直  vertical: false, //是否自動切換  autoplay: true, //自動切換的間隔 interval: 3000, //滑動動畫時長毫秒  duration: 1000, //所有圖片的高度  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; //把每一張圖片的對應的高度記錄到數組里  imgheights[e.target.dataset.id] = imgheight; this.setData({ imgheights: imgheights }) }, bindchange: function (e) { // console.log(e.detail.current) this.setData({ current: e.detail.current }) }, }})

wxml:

<!-------------首頁輪播圖----------------- --><view class='swiper'> <swiper indicator-dots="{{indicatorDots}}" vertical="{{vertical}}" autoplay="{{autoplay}}" duration="{{duration}}" interval='{{interval}}'indicator-active-color="#007aff" bindchange="bindchange" circular="{{circular}}" style="height:{{imgheights[current]}}rpx;"> <block wx:for='{{imgUrls}}' 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;} .swiper-image { height: 100%; width: 100%;} .slide-image { height: 100%; width: 100%; display: block;}

以上就是本文的全部內容,希望對大家的學習有所幫助,也希望大家多多支持錯新站長站。

發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 大埔县| 武平县| 郸城县| 余江县| 安陆市| 鄂州市| 荣成市| 巴林左旗| 武鸣县| 绩溪县| 合江县| 镇巴县| 华亭县| 琼结县| 永平县| 安平县| 罗甸县| 晋中市| 仪征市| 胶州市| 孝义市| 黄梅县| 双城市| 获嘉县| 南华县| 江西省| 苍溪县| 元朗区| 株洲市| 京山县| 连平县| 崇阳县| 临邑县| 衡水市| 景东| 汶川县| 温宿县| 白沙| 壤塘县| 天台县| 仁怀市|