var orderTimeOut = 900000;
var timer = setInterval(() => {
orderTimeOut -= 10;
if (orderTimeOut > 10) {
times = overTime(orderTimeOut);
console.log(times)
}else {
orderTimeOut = 0;
times = "00:00:00";
}
}, 10);
function overTime(time) {
var a = (time % 1000).toString().substr(0, 2);
var b = Math.floor(time / 1000);
var m = b % 60;
m = String(m);
m = m.length >= 2 ? m : "0" + m;
var f = Math.floor(time / (1000 * 60));
f = String(f);
f = f.length >= 2 ? f : "0" + f;
return f + ":" + m + "." + a;
}
这段方法 能够正常进行倒计时,但是观察到,它似乎越跑越慢.....
守候你守候我
慕村9548890
函数式编程
相关分类