JavaScript 倒计时的简单实现
on Front-End
function countDown (time) {
let self = this;
if (time === 0) {
clearTimeout(self.countTime);
delete self.countTime;
return;
} else {
time--;
}
self.countTime = setTimeout(function () {
self.countDown(time);
}, 1000);
}