var swiper = new Swiper("#swiper1", {
slidesPerView: 3,
observer:true,
observeParents:true,
grid: {
rows: 2,
},
spaceBetween: 30,
pagination: {
el: ".swiper-pagination",
clickable: true,
},
});
-
observer:true,//修改swiper自己或子元素时,自动初始化swiper
-
observeParents:true,//修改swiper的父元素时,自动初始化swiper 加上这两个属性就可以了