把slideChangeTransitionEnd(swiper)事件改为transitionEnd(swiper)事件
- slideChangeTransitionEnd(swiper)事件
swiper从一个slide过渡到另一个slide结束时执行 - transitionEnd(swiper)事件
过渡结束时触发
但transitionEnd(swiper事件)也有个问题,轻轻滑动当前页面,但不造成页面切换,这个函数也会触发,这时可以增加一个判断条件,把原有的索引值记录在变量currentSlide里,和该方法触发时的swiper.activeIndex进行比较
if (swiper.activeIndex == currentSlide) {
console.log('不能更新current')
} else {
currentSlide = swiper.activeIndex;
console.log('更新current') }
...
//进行相应操作
}