How to update Swiper slides in this situation!

Swiper introduces and initializes code to write every other function into an object. This is the first time I"ve seen this!

var win={
"slide_Swiper":function (){
 $.getScript("https://cdnjs.cloudflare.com/ajax/libs/Swiper/4.x.x/js/swiper.min.js",function() {
         var mySwiper3 = new Swiper(".swiper-container",{
           direction : "vertical",
            autoplay: {
              delay: 2000,
              stopOnLastSlide: false,
              disableOnInteraction: true,
            },speed: 2000,
        });
            
        }
    }() 
    
}

my template has changed the size, when the screen change is to reinitialize the mySwiper slide,
but I wrote the browser Uncaught ReferenceError: mySwiper3 is not defined error, I don"t know how to click to reinitialize the slide.

    $("-sharpSwiper_update").click(function(){
        win.slide_Swiper();
        mySwiper3.update();
        console.log("")
    })
Dec.04,2021

this does not need to be called and is already executed on the move. If you need to adjust, just register mySwiper3 directly under window


you execute win.slide_Swiper () asynchronously. At this time, the asynchronous execution is not finished, and mySwiper3 cannot be found. MySwiper3.update (); can be written to the request callback!

Menu