WXML代码如下:
<swiper autoplay=“true” interval=“3000” circular=“true” duration=“800” bindchange=“swiperChange”>
<block wx:for="{{imgUrls}}" wx:key=“index”>
<swiper-item>
<image src="{{item}}" class=“slide-image” />
</swiper-item>
</block>
</swiper>
<view class=“dots”>
<block wx:for="{{imgUrls}}" wx:key=“index”>
<view class=“dot{{index == currentSwiper ? ’ active’ : ‘’}}”></view>
</block>
</view>
js代码
swiperChange(e) {
let current = e.detail.current;
this.setData({
currentSwiper: current,
})
},