解决:使用 swiper 自动轮播图片,当拖动过 swiper 内的内容时,导致不继续自动轮播

当使用了 swiper 后:

var mySwiper = new Swiper('.banner .swiper-container', {
    autoplay: 3000,
    loop: true,
    pagination: '.swiper-pagination',
    autoplayDisableOnInteraction : false
})
解决办法即是设置这个参数: autoplayDisableOnInteraction 

官网给出的参数介绍:

用户操作 swiper 之后,是否禁止 autoplay 。默认为 true:停止。
如果设置为 false,用户操作 swiper 之后自动切换不会停止,每次都会重新启动 autoplay。
操作包括 触碰,拖动,点击 pagination 等。

猜你喜欢

转载自www.cnblogs.com/JaneBlog/p/8963358.html