收藏
回答

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 个回答

登录 后发表内容
问题标签