//参数是分钟,是毫秒就得除1000
//倒计时
countdown (msec) {
//计算秒
// let day = parseInt(msec / 1000 / 60 / 60 / 24)
let hr = parseInt(msec / 60 / 60 % 24)
let min = parseInt(msec / 60 % 60)
let sec = parseInt(msec % 60)
// this.day = day
this.hr = hr > 9 ? hr : '0' + hr
this.min = min > 9 ? min : '0' + min
this.sec = sec > 9 ? sec : '0' + sec
const that = this
if(min>=0 && sec>=0){
//倒计时结束关闭订单
if(min==0 && sec==0){
clearInterval()
return
}
setTimeout(function () {
//clearTimeout()
that.countdown(msec-1)
}, 1000)
}
},
js倒计时
最新推荐文章于 2024-12-03 11:08:57 发布