swiper.js 循环模式下索引不正确的解决方法

根据文档,我获取 swiper 当前索引值用的是activeIndex

  swiper.on('slideChangeTransitionEnd', function () {
      console.log('swiper当前索引:',swiper.activeIndex);
}

但是在swiper配置了loop:true ,开启循环之后,索引 打印出来是错的…

在循环模式下,获取索引要通过realIndex,

console.log('swiper当前索引:',swiper.realIndex); // loop 模式下 realIndex
上一篇 为什么要把方法定义在原型上而不是构造函数中
下一篇 在axios interceptors(拦截器)中引用vue实例上的方法,vuex