zoukankan      html  css  js  c++  java
  • swiper页面刷新布局和指示点错乱

    swiper轮播时,用到定时请求后台数据的场景,造成页面刷新时轮播图的指示点和轮播内容错乱。

    解决方法是:

    声明一个全局变量,轮播时进行销毁  这里我是把轮播为方法

    var mySwiper = 0; 
                   function play(){
                                if (mySwiper !== 0) {
                                    mySwiper.destroy();
                                }
                                mySwiper = new Swiper('.swiper-container', {
                                    observer: true,
                                    observeParents: true,
                                    // direction: 'vertical', // 垂直切换选项
                                    loop: true, // 循环模式选项
                                    autoplay: {
                                        delay: 3000,
                                        stopOnLastSlide: false,
                                        disableOnInteraction: false,
                                    },
                                    pagination: {
                                        el: '.swiper-pagination',
                                        clickable: true
                                    },
                                    // 如果需要前进后退按钮
                                    navigation: {
                                        nextEl: '.next',
                                        prevEl: '.prev'
                                    },
                                })
                            }
  • 相关阅读:
    Language Integrated Query
    为什么说 LINQ 要胜过 SQL
    LINQ(Language Integrated Query)
    Rx (Reactive Extensions)介绍
    ReactiveX Operators
    ReactiveX
    给 iOS 开发者的 RxSwift(一)
    The features of Swift
    RxSwift源码与模式分析一:基本类
    智力
  • 原文地址:https://www.cnblogs.com/shiraly/p/13139823.html
Copyright © 2011-2022 走看看