动态改变已经渲染出来的swiper
语法:
javascript
swiper的实例.params
例:
javascript
let cl_w = document.documentElement.clientWidth || document.body.clientWidth;
let myswiper = null;
window.addEventListener("resize",() => {
return (() => {
cl_w = document.documentElement.clientWidth || document.body.clientWidth;
myswiper.params.slidesPerView = cl_w > 750 ? 1.55 : 1.1;
myswiper.params.spaceBetween = cl_w > 750 ? 20 : 10;
})()
});
$(document).ready(()=>{
myswiper = new Swiper('.h_right_img', {
slidesPerView: cl_w > 750 ? 1.55 : 1.1,
spaceBetween: cl_w > 750 ? 20 : 10,
freeMode: true,
loop:true,
centeredSlides: true,
navigation: {
nextEl: ".swiper-button-next",
prevEl: ".swiper-button-prev",
},
pagination: {
el: '.swiper-pagination',
dynamicBullets: true,
clickable: true,
},
});
});