微信小程序使用swiper組件實(shí)現(xiàn)層疊輪播圖
本文實(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í)有所幫助,也希望大家多多支持腳本之家。
- 微信小程序 swiper組件輪播圖詳解及實(shí)例
 - 微信小程序之swiper輪播圖中的圖片自適應(yīng)高度的方法
 - 微信小程序視圖容器(swiper)組件創(chuàng)建輪播圖
 - 微信小程序使用swiper組件實(shí)現(xiàn)類3D輪播圖
 - 微信小程序 輪播圖swiper詳解及實(shí)例(源碼下載)
 - 微信小程序?qū)崿F(xiàn)的3d輪播圖效果示例【基于swiper組件】
 - 微信小程序?qū)崿F(xiàn)Swiper輪播圖效果
 - 微信小程序輪播圖swiper代碼詳解
 - 微信小程序非swiper組件實(shí)現(xiàn)的自定義偽3D輪播圖效果示例
 - 微信小程序swiper輪播圖組件使用方法詳解
 
相關(guān)文章
 JS+CSS實(shí)現(xiàn)炫酷算盤(pán)時(shí)鐘效果
這篇文章主要為大家詳細(xì)介紹了如何使用JavaScript和CSS實(shí)現(xiàn)炫酷算盤(pán)時(shí)鐘效果,文中的示例代碼講解詳細(xì),感興趣的小伙伴可以跟隨小編一起學(xué)習(xí)一下2023-12-12
 原生js實(shí)現(xiàn)回復(fù)評(píng)論功能
本文主要分享了原生js實(shí)現(xiàn)回復(fù)評(píng)論功能的示例代碼。具有一定的參考價(jià)值,下面跟著小編一起來(lái)看下吧2017-01-01
 一篇文章帶你吃透JavaScript中的DOM知識(shí)及用法
DOM作用:用來(lái)修改網(wǎng)頁(yè)內(nèi)容,結(jié)構(gòu)和樣式,下面這篇文章主要給大家介紹了關(guān)于如何通過(guò)一篇文章帶你吃透JavaScript中的DOM知識(shí)及用法的相關(guān)資料,文中通過(guò)實(shí)例代碼介紹的非常詳細(xì),需要的朋友可以參考下2022-11-11
 ES6中解構(gòu)賦值實(shí)現(xiàn)變量批量賦值解放雙手
這篇文章主要為大家介紹了ES6中解構(gòu)賦值實(shí)現(xiàn)變量批量賦值解放雙手,變量的解構(gòu)賦值,聽(tīng)起來(lái)很復(fù)雜,簡(jiǎn)單點(diǎn)說(shuō)可以理解成批量操作變量賦值2022-04-04
 js+html5實(shí)現(xiàn)頁(yè)面可刷新的倒計(jì)時(shí)效果
這篇文章主要為大家詳細(xì)介紹了js+html5實(shí)現(xiàn)頁(yè)面可刷新的倒計(jì)時(shí)效果,具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下2017-07-07
 JS實(shí)現(xiàn)網(wǎng)頁(yè)Div層Clone拖拽效果
這篇文章主要介紹了JS實(shí)現(xiàn)網(wǎng)頁(yè)Div層Clone拖拽效果,涉及JavaScript響應(yīng)鼠標(biāo)事件動(dòng)態(tài)改變頁(yè)面元素位置屬性及層級(jí)屬性的相關(guān)技巧,具有一定參考借鑒價(jià)值,需要的朋友可以參考下2015-09-09
 使用JSON.parse將json字符串轉(zhuǎn)換成json對(duì)象的時(shí)候會(huì)出錯(cuò)
使用JSON.parse將json字符串轉(zhuǎn)換成json對(duì)象的時(shí)候會(huì)出錯(cuò),主要是雙引號(hào),回車(chē)換行等影響明顯,左尖括號(hào)和右尖括號(hào)也會(huì)導(dǎo)致顯示問(wèn)題2014-09-09

