对于swiper有不同版本,不同的版本使用方法也不同。
对于swiper3,实现鼠标移入停止滚动,移出开始滚动原生使用以下方法
// 鼠标移入停止自动滚动
$('.swiper-slide').mouseenter(function() {
mySwiper.stopAutoplay();
})
// 鼠标移出开始自动滚动
$('.swiper-slide').mouseleave(function() {
mySwiper.startAutoplay()
})
使用swiper3,loop循环且自动播放,初始化时出现transform移动距离不够问题,可能是初始化时没有获取到宽度,对swiper-wrapper设置一个宽度或者最小宽度解决。