swiper 添加左右按钮时,swiper数量小于3张时,点击左右按钮不能衔接滑动滑动?
<view class="anniversary_myprize_inner">
<view class="swiper_prev" bindtap='prevImg'></view>
<swiper class="anniversary_prize_swiper" indicator-dots="{{ prizeList.length > 0 }}" display-multiple-items="1" bindchange="swiper" current="{{ current }}" indicator-color="#ffcd0c" indicator-active-color="#ffffff" circular>
<swiper-item wx:for="{{ prizeList }}" wx:key="index">
<view class="anniversary_store_prize">
<image wx:if="{{ item.prize_id }}" src="https://member-mp-stg.eloccitane.com/locapp/api/public/static/images/anniversary/prize_{{ item.prize_id }}.png?v=0.7" class='w100' mode="widthFix" />
</view>
<view class="anniversary_store_prize_name" wx:if="{{ item.prize_id == 1 }}">焕活微囊肌底精华液 30ML</view>
</swiper-item>
</swiper>
<view class="swiper_next" bindtap='nextImg'></view>
</view>
data: {
prizeList: [
{},
{},
]
current: 0
}
/**
* swiper 左右按钮
*/
prevImg(e) {
console.log(e);
let that = this,
swiper = that.data.prizeList,
current = that.data.current;
swiper.current = current > 0 ? current - 1 : swiper.length - 1;
that.setData({
prizeList: swiper,
current: swiper.current
})
},
nextImg() {
let that = this,
swiper = that.data.prizeList,
current = that.data.current;
swiper.current = current < (swiper.length - 1) ? current + 1 : 0;
that.setData({
prizeList: swiper,
current: swiper.current
})
},
1 回复
你好,麻烦提供出现问题的具体机型、微信版本号、系统版本号,以及能复现问题的代码片段(https://developers.weixin.qq.com/miniprogram/dev/devtools/minicode.html),并描述下复现的流程。