最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

微信小程序使用swiper組件實(shí)現(xiàn)層疊輪播圖

 更新時(shí)間:2021年04月19日 09:30:30   作者:瑪咪啞哄  
這篇文章主要為大家詳細(xì)介紹了微信小程序使用swiper組件實(shí)現(xiàn)層疊輪播圖,文中示例代碼介紹的非常詳細(xì),具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下

本文實(shí)例為大家分享了微信小程序?qū)崿F(xiàn)層疊輪播圖的具體代碼,供大家參考,具體內(nèi)容如下

wxml:

<view class="banner-swiper">
 <swiper indicator-dots="{{indicatorDots}}" autoplay="{{autoplay}}" current='{{swiperCurrent}}' 
indicator-color="{{beforeColor}}" indicator-active-color="{{afterColor}}" circular='{{circular}}' 
previous-margin="{{previousmargin}}" next-margin="{{nextmargin}}" bindchange="swiperChange" >
 <block wx:for="{{arr}}" wx:key="key"> 
  <swiper-item>
  <image src="{{item.images}}" class="slide-image{{index == swiperCurrent ? ' active' : ''}}" 
bindchange="chuangEvent" id="{{index}}"></image>
  </swiper-item>
 </block> 
 </swiper>
 </view> 

wxss:

.banner-swiper {
 width: 100%;
 height: 500rpx;
 overflow: hidden;
}

swiper {
 display: block;
 height: 500rpx;
 position: relative;
}

.slide-image {
 width: 96%;
 display: block;
 margin: 0 auto;
 height: 450rpx;
 margin-top:25rpx;
}
.active{
 margin-top:0rpx;
 height: 500rpx;
}

js:

Page({
 data: {
 //輪播圖
 swiperCurrent:1,
 arr: [{
 images: 'images/1.jpg'
 },
 {
 images: 'images/5.jpg'
 },
 {
 images: 'images/3.jpg'
 },
 {
 images: 'images/4.jpg'
 }
 ]
 indicatorDots: true,
 autoplay: true,
 interval: 2000,
 duration: 1000,
 circular: true,
 beforeColor: "white",//指示點(diǎn)顏色 
 afterColor: "coral",//當(dāng)前選中的指示點(diǎn)顏色 
 previousmargin:'30px',//前邊距
 nextmargin:'30px',//后邊距
 
 },
 
 //輪播圖的切換事件 
 swiperChange: function (e) {
 console.log(e.detail.current);
 this.setData({
 swiperCurrent: e.detail.current //獲取當(dāng)前輪播圖片的下標(biāo)
 })
 },
 //滑動(dòng)圖片切換 
 chuangEvent: function (e) { 
 this.setData({
 swiperCurrent: e.currentTarget.id
 })
 },
})

效果圖:

以上就是本文的全部?jī)?nèi)容,希望對(duì)大家的學(xué)習(xí)有所幫助,也希望大家多多支持腳本之家。

相關(guān)文章

最新評(píng)論

筠连县| 德江县| 闵行区| 历史| 西华县| 施秉县| 东明县| 保靖县| 江口县| 抚远县| 花垣县| 海城市| 晋州市| 闵行区| 昭平县| 睢宁县| 抚远县| 合江县| 泉州市| 东城区| 郴州市| 通许县| 曲水县| 恩平市| 蕉岭县| 威信县| 乌鲁木齐市| 舟曲县| 古田县| 自贡市| 鄯善县| 长武县| 涡阳县| 池州市| 大宁县| 洛隆县| 平邑县| 札达县| 滨州市| 香港 | 大田县|