下载 使用 swiper

cnpm i swiper@3.4.2 --save-dev

main.js 中

import Swiper from 'swiper'
import 'swiper/dist/css/swiper.css'

vue swiper自定义分页器

 var  swiper = new Swiper(".feature", {
        ....
        //前进后退后自动播放
        //用户操作swiper之后,是否禁止 autoplay 。默认为true:停止。
        autoplayDisableOnInteraction: false,
        //分页器 
        pagination: ".swiper-pagin",
        paginationClickable: true,  //点击分页器 进行切换swiper
        
        //以下 自定义分页器  类名默认 swiper-pagination-bullet  ,
        // active类名默认· swiper-pagination-bullet-active
        paginationBulletRender: function (swiper, index, className) {
          console.log(className); //默认类名 swiper-pagination-bullet
          return '<div class="' + className + '"></div>';
        },
      });

css样式 ()

父类名 /deep/ .swiper-pagination-bullet {
  height: 0.1rem;
  width: 0.025rem;
  background-color: #000;
  display: inline-block;
  margin-right: 0.1rem;
  opacity: 1;  //默认样式有透明度,这里修改了
  transition: all 0.25s; //swiper分页器过渡效果
}
//当前swiper对象 css样式
父类名 /deep/ .swiper-pagination-bullet-active {
  height: 0.16rem;
}

效果(高度上的改变)
在这里插入图片描述

Logo

魔乐社区(Modelers.cn) 是一个中立、公益的人工智能社区,提供人工智能工具、模型、数据的托管、展示与应用协同服务,为人工智能开发及爱好者搭建开放的学习交流平台。社区通过理事会方式运作,由全产业链共同建设、共同运营、共同享有,推动国产AI生态繁荣发展。

更多推荐