本文实例为大家分享了swiper自定义分页器的样式代码,供大家参考,具体内容如下
js主要代码
pagination: {
// 自定义分页器的类名----必填项
el: '.custom-pagination',
// 是否可点击----必填项
clickable: true,
// 分页的类型是自定义的----必填项
type: 'custom',
// 自定义特殊类型分页器,当分页器类型设置为自定义时可用。
renderCustom: function (swiper, current, total) {
console.log(current);//1 2 3 4
}
},
一、el
分页器容器的css选择器或HTML标签。分页器等组件可以置于container之外,不同Swiper的组件应该有所区分,如#pagination1,#pagination2。
二、分页器样式类型 可选
‘bullets' 圆点(默认)
‘fraction' 分式
‘progressbar' 进度条
‘custom' 自定义
三、renderCustom()
自定义特殊类型分页器,当分页器类型设置为自定义时可用。
四、slideToLoop()
在Loop模式下Swiper切换到指定slide。切换到的是slide索引是realIndex
源码
document * { margin: 0; padding: 0; } ul { list-style: none; text-align: center; overflow: hidden; } a { text-decoration: none; color: #000; } .swiper-content { width: 80%; overflow: hidden; margin: 0 auto; } .swiper-content .title { height: 100px; display: flex; align-items: center; justify-content: space-around; } .swiper-content .nav-item { float: left; display: block; margin-right: 30px; width: 50px; height: 30px; line-height: 30px; } .swiper-content .nav-item.active { background-color: #378ee6; } .swiper-content .swiper-container { height: 300px; background-color: pink; } 1 2 3 4
以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持考高分网。



