我在Swiper Slider上遇到麻烦,我在脚本中使用“appendSlide”,当我滚动到页脚,swiper附加新幻灯片,页面向上滚动到滑块
var mySwiper = new Swiper('.swiper-container', {
// Optional parameters
direction: 'horizontal',
slidesPerView: '1',
touchRatio: '1',
loop: true,
nextButton: '.swiper-button-next',
prevButton: '.swiper-button-prev'
});
function loadcontent () {
var id = $('.catslide>.swiper-wrapper>.swiper-slide-active').attr('data-id');
$.ajax({
type: "POST",
url: "../showthis.php",
data: {
id:id,
rand:1
},
datatype: 'json',
success: function (data) {
mySwiper.removeAllSlides();
mySwiper.appendSlide(data);
mySwiper.update();
}
});
}
categories.on('slideChangeStart', function () {
loadcontent();
});