美文网首页
swiper点击事件(复制的没有点击事件bug)

swiper点击事件(复制的没有点击事件bug)

作者: 给我小前端 | 来源:发表于2023-10-17 10:54 被阅读0次

new Swiper('.swiper-container', {
slidesPerView: 2,
spaceBetween: 10,
// 如果需要前进后退按钮
nextButton: '.swiper-button-next',
prevButton: '.swiper-button-prev',
loop: true,
autoplay: {
delay: 3000,
},
speed:1500,
on: {
click: function () {
// 这里有坑,需要注意的是:this 指向的是 swpier 实例,而不是当前的 vue, 因此借助 vm,来调用 methods 里的方法
// console.log(this); // -> Swiper
// 当前活动块的索引,与activeIndex不同的是,在loop模式下不会将 复制的块 的数量计算在内。
const realIndex = this.realIndex;
self.handleClickSlide(realIndex);
}
}
})

相关文章

网友评论

      本文标题:swiper点击事件(复制的没有点击事件bug)

      本文链接:https://www.haomeiwen.com/subject/ennfidtx.html