如何在鼠标进入时停止滑动自动播放和在鼠标离开时开始自动播放?我尝试了.stopAutoPlay()和.startautoPlay()函数,但对我不起作用。
谢谢。这是代码。
var swiper = new Swiper('.swiper-container', {
pagination: '.swiper-pagination',
paginationClickable: true,
nextButton: '.swiper-button-next',
prevButton: '.swiper-button-prev',
spaceBetween: 0,
loop: true,
effect: 'slide',
longSwipes: true,
autoplay:2000,
autoplayDisableOnInteraction:true,
});
$(".swiper-container").mouseenter(function(){
swiper.stopAutoPlay();
});
$(".swiper-container").mouseleave(function(){
swiper.startAutoPlay();
});
检查swiper API文档,u应该使用mySwiper.startautoplay(),字母“P”是小写的