• swiper4的用法


    1.swiper:HTML结构

    <div class="swiper-container">
        <div class="swiper-wrapper">
            <div class="swiper-slide">slider1</div>
            <div class="swiper-slide">slider2</div>
            <div class="swiper-slide">slider3</div>
        </div>
    </div>
    

      2.样式

           .swiper-container{
                margin:0 auto;
                100px;
                height:200px;
                overflow: hidden;
                border:1px solid red;
            }
            .swiper-wrapper,.swiper-slide{
                100px;
                height:200px;
            }
    

      3.水平轮播

    var mySwiper = new Swiper('.swiper-container', {
            autoplay: true,//可选选项,自动滑动
            loop:true
        })
    

      4.垂直轮播

        var mySwiper = new Swiper('.swiper-container', {
            autoplay: true,//可选选项,自动滑动
            direction : 'vertical',//控制滚动的方向,水平或垂直
            loop:true
        })
    

      5.轮播可视区域展示多个slide项

       var mySwiper = new Swiper('.swiper-container', {
            autoplay: true,//可选选项,自动滑动
            direction : 'vertical',
            loop:true,
            slidesPerView : 3,//设置slider容器能够同时显示的slides数量(carousel模式)
        })
    

      

      6.左右切换,获取activeIndex的值

    var mySwiper = new Swiper('.swiper-container',{
      on: {
        //slideChangeTransitionStart开始切换时告诉我现在是第几个slide
    
    
        slideChangeTransitionEnd: function(){
          alert(this.activeIndex);//切换结束时,告诉我现在是第几个slide
        },
      },
    })
    

      7.分页1/3展示效果

    var mySwiper = new Swiper('.swiper-container',{
        pagination: {
           el: '.swiper-pagination',
           type:'fraction',
           //type: 'bullets',圆点默认
           //type: 'fraction',分页
           //type : 'progressbar',进度条
           //type : 'custom',自定义
         },
    
    })
    

      8.延迟加载图片

      9.滚动条

      10.缩略图

      11.锚导航

  • 相关阅读:
    2019-9-10做题记录
    2019-9-9做题记录
    【HAOI2008】硬币购物
    【SCOI2010】生成字符串
    第18讲——ActiveX控件
    第20讲 HOOK和数据库编程
    第19讲——动态链接库
    2016-5-22 百度之星第三题--瞬间移动
    2016-4-25 完美世界-实习--小萌的包裹
    第3章 拍摄UFO——单一职责原则
  • 原文地址:https://www.cnblogs.com/dyy-dida/p/11128345.html
Copyright © 2020-2023  润新知