小程序swiper卡死

2019-05-27  本文已影响0人  无名小码农

小程序swiper滑动卡死问题

原因可能是swiper组件内部问题,当无法响应用户快速翻动动作时,当前页变量current无法变更为正确页码索引,而是被置为0,
    console.log(e.detail.current);
    if (e.detail.source == "touch") {
      //防止swiper控件卡死
      if (this.data.current == 0 && this.data.dailySpikeIndex > 1) {//卡死时,重置current为正确索引
        this.setData({ dailySpikeIndex: this.data.dailySpikeIndex });
      }
      else {//正常轮转时,记录正确页码索引
        this.setData({ dailySpikeIndex: e.detail.current });
      }
    }
  },
上一篇 下一篇

猜你喜欢

热点阅读