为了账号安全,请及时绑定邮箱和手机立即绑定

滑动滑动自定义计数器(分数)

滑动滑动自定义计数器(分数)

慕哥6287543 2023-03-03 09:43:23
我使用 swiper slider 并且有反分数。它计数很好,但我需要计数 =(所有幻灯片 - 1)。例如,如果我有 20 张幻灯片,我想显示总数 19。有什么办法可以做到这一点吗?我使用他们网站上的常规 js。这是我所拥有的:var gallery = new Swiper('.left-side-slider-gallery', {  slidesPerView: '1',  pagination: {  el: '.jail-app-left-side-fractions',  type: 'fraction',  },});
查看完整描述

1 回答

?
红糖糍粑

TA贡献1815条经验 获得超6个赞

您可以使用文档中提到的custom类型和函数:renderCustom

var gallery = new Swiper('.left-side-slider-gallery', {

  slidesPerView: 1,

  pagination: {

    el: '.jail-app-left-side-fractions',

    type: 'custom',

    renderCustom: function (swiper, current, total) {

        return current + '/' + (total - 1); 

    }

  }

});




查看完整回答
反对 回复 2023-03-03
  • 1 回答
  • 0 关注
  • 62 浏览
慕课专栏
更多

添加回答

举报

0/150
提交
取消
意见反馈 帮助中心 APP下载
官方微信