不说这么多,直接上代码
<swiper class="swiper-block" previous-margin="90rpx" next-margin="90rpx" autoplay="{{yearOutoplay}}" current="0" circular=‘true‘ bindchange="yearSwiperChange" > <block wx:for="{{yearimgUrls}}" wx:index="{{index}}" wx:key=‘‘> <swiper-item class="swiper-item"> <image mode="aspectFill" src="{{item.url}}" class="slide-image {{swiperCurrent == index ? ‘active‘ : ‘‘}}"/> </swiper-item> </block> </swiper>
swiperCurrent: 0, yearOutoplay:false, yearimgUrls: [ { url:‘../../images/banner.jpg‘, }, { url:‘../../images/banner.jpg‘, }, { url:‘../../images/banner.jpg‘, }, ],
yearSwiperChange(e) {
let current = e.detail.current;
let that = this;
that.setData({
swiperCurrent: current,
})
},
原文地址:https://www.cnblogs.com/liujun1128/p/10730310.html
时间: 2024-10-04 16:31:06