swiper常用配置

 

 

<script>        
  var mySwiper = new Swiper ('.swiper-container', {
                    autoplay: {
                        delay:5000,//秒            
                        disableOnInteraction: false,//滑动不会失效
                        reverseDirection: false,//如果最后一个 反向播放
                    },
                    loop: true,//轮播
                    followFinger: false,//手指滑动完毕在动
    // 如果需要分页器
      pagination: {
        el: '.swiper-pagination',
        clickable: true,
        renderBullet: function (index, className) {
          return '<span class="' + className + '">' + (index + 1) + '</span>';
        },
      },
    
    // 如果需要前进后退按钮
    navigation: {
      nextEl: '.swiper-button-next',
      prevEl: '.swiper-button-prev',
    },
    
  });
    mySwiper.el.onmouseover = function(){ //鼠标放上暂停轮播
      mySwiper.autoplay.stop();
    }
    mySwiper.el.onmouseleave = function(){
      mySwiper.autoplay.start();
    }
  </script>