微信小程序的swipe 在点击切换时,如果只有两个swipe-item,点击切换到方向不正常?

发布于 7 年前作者 lihao9798 次浏览最后编辑 7 年前来自 ask

 三个swipe-item是正常的,两个的话我看wipe-item的transform没有动态改变,从第一个点击向右按钮切换到第二个,切换方向向右,,再点击回到第一个,切换方向是向左切换的,怎么能回到第一个时方向也向右?

两个按钮的点击事件

向前,向后按钮的点击事件,我是通过动态改变current参数的值  
prevClick() {
      const num = this.current > 0 ? this.current - 1 : this.option.length - 1;
      this.current = num;
    },
    nextCLick() {
      const num = this.current < this.option.length - 1 ? this.current + 1 : 0;
      this.current = num;
    },
有没有大神看下能不能有更好的方法?

1 回复
junyu
junyu1 楼4 年前

circular属性写上