大家好,我正在尝试让我的滑块选择动态改变窗口的宽度并将正确的变量“newscount”放入“slidesPerSlide:window.newscount”并重新加载最后一部分:
swiperLoop = $('.swiper-loop').swiper({
slidesPerSlide : window.newscount,
loop:false
});
请帮助我,代码如下:
$(window).on('load', function(){
$(window).on('resize', function() {
var w = $(window).width();
if (w < 321) {
var newscount = "2";
}
else if (w < 480) {
var newscount = "3";
}
else if (w < 640) {
var newscount = "5";
}
else if (w < 720) {
var newscount = "8";
}
else if (w > 721) {
var newscount = "8";
}
});
swiperLoop = $('.swiper-loop').swiper({
slidesPerSlide : window.newscount,
loop:false
});
});