var currSwiperIndex=0; function widthHandle(){ var level = widthLevel(); if(level==1){ //单个显示,滑动 if(mySwiper==null){ mySwiper = new Swiper('.swiper-container',{ initialSlide: currSwiperIndex, }); } }else{ //4个都显示 if(mySwiper!=null){ currSwiperIndex = mySwiper.activeIndex; mySwiper.destroy(true,true); mySwiper = null; } var width = $(".container").width(); $(".gonggao").css("width",width/4+"px"); } }