最近項目首頁輪播圖用了Swiper輪播,今天突然發現輪播圖動畫初始正常但是手動換過之后就不動了,解決方法有兩種,具體根據采用的情況為准:
1、autoplayDisableOnInteraction:false,
var mySwiper = new Swiper(".swiper-container", { autoplay: 3000, //可選選項,自動滑動 autoplayDisableOnInteraction:false, observer: true, observeParents: true, paginationClickable: true, watchSlidesProgress: true, watchSlidesVisibility: true });
當autoplayDisableOnInteraction:false的時候,手動滑動自動滑動不會失效
2、網上最多的:disableOnInteraction:false,
var mySwiper = new Swiper(".swiper-container", { autoplay: { delay: 2500, disableOnInteraction: false, }, observer: true, observeParents: true, paginationClickable: true, watchSlidesProgress: true, watchSlidesVisibility: true });
話不多說,其實只是寫法不用,屬性作用一樣。