总秒数
CountDown(){
let maxtime = 30 //倒计时间总秒数
this.timer = setInterval(()=>{
if (maxtime >= 0) {
let hour = Math.floor((maxtime / 3600) % 24);
let minutes = Math.floor((maxtime / 60) % 60);
let seconds = Math.floor(maxtime % 60);
this.msg = this.formatNum(hour) + ":"+ this.formatNum(minutes) + ":" + this.formatNum(seconds);
console.log(this.msg)
--maxtime;
} else{
clearInterval(this.timer);
}
},1000)
},
formatNum (num) {
return num < 10 ? '0' + num : '' + num
}
时-分-秒
hour = Math.floor(maxtime / 60/60);
minutes = Math.floor(maxtime / 60% 60);
seconds = Math.floor(maxtime % 60);