我已经看了一会儿,尝试了很多不同的修复方法。我让odometer正常工作(按计算应该),但当它到达一个零结尾的数字时,里程表会丢失最后一个小数位。我有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);