1. 程式人生 > >websocket 不重新整理頁面 swiper輪播出現多次new 定時器加速 已解決

websocket 不重新整理頁面 swiper輪播出現多次new 定時器加速 已解決

if(NewsHot=='out-1'){//滿足條件執行
    var swiper;
    $(".swiper-container").remove();//不管有沒有先刪除
    $(".thanks-top").after(//建立
    '<div class="swiper-container">'+
        '<div class="swiper-wrapper">'+
        '< img class="swiper-slide" src="img/swiper/advertise1.jpg"></img>' +
        '< img class="swiper-slide" src="img/swiper/advertise2.jpg"></img>'
+ '</div>'+ '</div>' ) if(swiper){ swiper.destroy(removeResizeEvent)//登出swiper任何事件 } console.log($(".swiper-wrapper").html()) swiper = new Swiper('.swiper-container', { spaceBetween: 15,//切換時空白間隔 autoplay: { delay: 2000, }, loop : true
, }); }

解決了,耶