zoukankan      html  css  js  c++  java
  • vueawesomeswiper自定义 导航点

    1,pagination的配置
    pagination: {
      el: '.swiper-paginationfull',
      // type:'bullets',
      // bulletElement : 'span',//设置分页器小圆点标签,默认为span标签
      // clickable:true,
      // paginationClickable: true,
      // notNextTick:true,
      // bulletClass: 'bullet-class',
      // bulletActiveClass: 'bullet-active-class',
      type:'custom',//自定义导航的前提设置
      renderCustom: function (swiper, current, total) {//current从1开始 total=5       有5个轮播页
        var customPaginationHtml = "";
        for(var i = 0; i < total; i++) {//加导航点
          if(i == (current - 1)) {
            customPaginationHtml += '<span class="bullet-class bullet-active-class"></span>';
          } else {
            customPaginationHtml += '<span class="bullet-class"></span>';
          }
        }
        for(var i = 0; i < total-1; i++){//加分割线(可不加 完全自定义)
          customPaginationHtml += '<div class="line"></div>'
        }
        return customPaginationHtml;
      }
    },
    2,//导航盒子 采用固定定位
    .swiper-paginationfull{
    position:fixed;
    top:50%;
    transform:translateY(-50%);
    left:98%;
    z-index:1;
    0.3rem;
    height:1.52rem;
    }
    3,//给导航点加点击事件   在mounted里            这里采用事件代理的方式
    $('.swiper-paginationfull').on('click','span',function(){
      var index = $(this).index();
      self.$refs.mySwiper.swiper.slideTo(index, 500, false);//切换到第一个slide,速度为0.5秒
    });
     
    中间的导航点样式可以自定义,想怎么写就怎么写,不过这些关于导航的样式需要import引入 在swiper实例化之前  我也不知道为啥
      script中写
    import '@/css/bullet.css';
  • 相关阅读:
    go资料
    typescript 装饰器 decorator
    【转】typescript class decorator装饰器
    【转】Best way to get result count before LIMIT was applied
    DirectX11 采样状态对象
    React通过redux-persist持久化数据存储
    禁止网页查看源代码
    css3 动画 -- 加载动画 Loader
    css3 动画 -- 旋转线条 rotate_line
    读书打卡:《微信互联网平民创业》
  • 原文地址:https://www.cnblogs.com/fqh123/p/9924331.html
Copyright © 2011-2022 走看看