我已经环顾了一段时间,并尝试了许多不同的修复方法。我的里程表工作正常,(按它应该的方式计数)但是当它碰到一个最后为零的数字时,里程表会丢失最后一个小数位。我有toFix()
我认为会工作但不是。我已经在这把小提琴上设置好了。
小提琴http://jsfiddle.net/mb91t1Ln/4/
这是我从以下位置获得插件的地方:http: //github.hubspot.com/odometer/
var placement = document.querySelector('.odometer');
var startValue = placement.innerHTML;
var increase = 0.01;
var seconds = $('.odometer').data("seconds");
var speed = (1 / seconds) * 10;
jackpotOdometer = new Odometer({
el: placement,
value: startValue,
format: '(,ddd).dd'
});
var current = jackpotOdometer.value;
//console.log("current = " + current);
setInterval(function(){
//var parsed = parseInt(increase);
//jackpotOdometer.update(current + increase);
//var fixedCurrentNumber = currentPlusIncrease.toFixed(2);
//console.log("Fixed Current Number = " + fixedCurrentNumber);
//current = current.toFixed(2) + increase.toFixed(2);
var num = (current += increase).toFixed(2);
console.log("current = " + num);
jackpotOdometer.update(num);
}, speed);