直接上代码:
//倒计时
countDown(TIME){
let timeHander = setInterval(()=>{
TIME--;
// 计算分钟数
let minute:any = Math.floor(this.utils.accDiv(TIME,60));
minute = minute < 10 ? '0' + minute : minute;
// 计算秒数
let second:any = this.utils.Subtr(TIME,this.utils.accMulti(minute,60));
second = Math.floor(second);
second = second < 10 ? '0' + second : second;
// 返回结果格式 29:59
this.downTime = minute + ':' + second;
if(parseInt(minute)==0 && parseInt(second)==0){
clearInterval(timeHander);
return;
}
},1000)
}
调用: