事件总结
.resize() 当浏览器窗口变化时 swiper的个数发生变化总结 把swiper的js挨个修改
$(function() { createSwiper(); $(window).resize(function() { createSwiper() }); }); function createSwiper() { var ww = $(window).width(); // 关于我们 公司荣誉 轮播 开始 if (ww <= 480) { var honor = new Swiper('.c-honor .swiper-container', { slidesPerView: 2, slidesPerColumn: 2, paginationClickable: true, spaceBetween: 10, nextButton: '.swiper-button-next-honor', prevButton: '.swiper-button-prev-honor', }); } else if(ww <= 768) { var honor = new Swiper('.c-honor .swiper-container', { slidesPerView: 3, slidesPerColumn: 2, paginationClickable: true, spaceBetween: 20, nextButton: '.swiper-button-next-honor', prevButton: '.swiper-button-prev-honor', }); } else { var honor = new Swiper('.c-honor .swiper-container', { slidesPerView: 4, slidesPerColumn: 2, paginationClickable: true, spaceBetween: 30, nextButton: '.swiper-button-next-honor', prevButton: '.swiper-button-prev-honor', }); }
swiper总结