Odometer.js中数字开头支持0 [英] Support of 0 in the beginning of numbers in Odometer.js

查看:68
本文介绍了Odometer.js中数字开头支持0的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想使用里程表在我的html中显示数字.数字从100到1000万不等.我想要固定数量的数字.格式是什么?

I want to use odometer to show numbers in my html. Numbers vary from 100 to 10mn. I want to have a fixed number of digits. What is the format for that?

这是我一直在使用的:

  var total_ads1 = d3.select("body")
  .append("div")
  .attr("class", "total_ads");


  od = new Odometer({
    el: document.querySelector(".total_ads"),
    value: sum,
    format:'(dd,ddd,ddd)',
    theme:'car',
    duration:1000,
  });

每次必须打印较小的数字时,都会更改里程表中的像元数.我以为用文本更新内部html可能有用,但是看起来它在内部将其转换为数字.

Every time it has to print smaller number it alters the number of cells in the odometer. I thought updating the inner html with text might work but it looks like it converts it internally to numbers.

推荐答案

Michael发布了

Michael has posted a compiled version of his workaround! Great job.
You can use it instead of the official version and specify in his script a Minimum Integer length:

MIN_INTEGER_LEN = 0;

这篇关于Odometer.js中数字开头支持0的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆