Sign in

How to update swiper slide in this case!

MichaelK edited in Sun, 08 May 2022

Swiper introduces and initializes code to write every function to an object. This is the first time I've seen this kind of writing!

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,

When the screen changes, I want to reinitialize my swiper slide. But when I write my browser as uncaught reference error: my swiper3 is not defined, I don't know how to click reinitialize this slide.

2 Replies
commented on Sun, 08 May 2022

This doesn't need to be called, it's already mobile. If you need to adjust, just register myswiper3 in the window

commented on Sun, 08 May 2022

You execute win.slide_ Swiper() is asynchronous. At this time, the asynchronous execution is not finished, and myswiper3 cannot be found. Myswiper3. Update(); can be written into the request callback!

lock This question has been locked and the reply function has been disabled.