有一个滑动滑块,现在分页看起来像1 - 3,我需要像01 - 03。
这里是一个演示
https://codepen.io/anakin-skywalker94/pen/RmWxbE
超文本标记语言
<!-- Slider main container -->
<div class="swiper-container">
<!-- Additional required wrapper -->
<div class="swiper-wrapper">
<!-- Slides -->
<div class="swiper-slide">Slide 1</div>
<div class="swiper-slide">Slide 2</div>
<div class="swiper-slide">Slide 3</div>
</div>
<!-- If we need pagination -->
<div class="swiper-pagination"></div>
</div>
JS系统
var swiper = new Swiper('.swiper-container', {
pagination: {
el: '.swiper-pagination',
type: 'fraction',
},
navigation: {
nextEl: '.swiper-button-next',
prevEl: '.swiper-button-prev',
},
direction: 'horizontal',
loop: true,
slidesPerView: 1,
spaceBetween: 0,
mousewheel: true,
pagination: {
el: '.swiper-pagination',
type: 'fraction',
clickable: true,
renderFraction: function (currentClass, totalClass) {
return '<span class="' + currentClass + '"></span>' + ' <span>-</span> ' + '<span class="' + totalClass + '"></span>'; }
},
});
谢谢!
4条答案
按热度按时间pb3s4cty1#
您可以使用类似
('0' + 4).slice(-2)
的代码,以便将0
添加到小于10
且大于0
的数字前面。所以你的JS看起来像这样:
请参见codepen上的工作演示:https://codepen.io/Orlandster/pen/jobZmz
z5btuh9x2#
由于其他答案不再起作用,这里是一个工作变体,具有某种简化的结构和最新的刷卡器版本:
yjghlzjz3#
6l7fqoea4#
滑动器9.0.1