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

chat
chat

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

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

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

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

console.log('swiper当前索引:',swiper.realIndex); // loop 模式下 realIndex
THE END
分享
二维码
海报
swiper.js 循环模式下索引不正确的解决方法
swiper.js 在loop循环模式下索引值错误的解决方法
<<上一篇
下一篇>>
chat