滑动滑块有问题。我希望滑鼠在鼠标进入时停止并在mouseleave上继续。但是我的控制台显示一个错误-> swiper.stopAutoplay不是一个功能,但是会显示控制台日志。与startAutoplay相同。有人知道我在做什么错吗?
<script>
var swiper = new Swiper('.swiper-container', {
loop: true,
speed:2000,
autoplay: {
delay: 3500,
},
pagination: {
el: '.swiper-pagination',
},
});
(function($) {
$('.swiper-container').on('mouseenter', function(e){
console.log('stop autoplay');
swiper.stopAutoplay();
})
$('.swiper-container').on('mouseleave', function(e){
console.log('start autoplay');
swiper.startAutoplay();
})
})(jQuery);
</script>
在版本中,4.3.5
您必须使用autoplay.stop
和autoplay.start
。例如:
var mySwiper = new Swiper('.my-swiper');
$('.my-swiper').hover(function() {
mySwiper.autoplay.stop();
}, function() {
mySwiper.autoplay.start();
});
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句