data:{
duration:num*60*60 //先将拿到的时(num)转为秒
h:'', //倒计时 时
m:'', //倒计时 分
s:'' //倒计时 秒
},
onLoad: function (option) {
this.getTime()
}
getTime(){
let time = this.data.duration
// 转换为时分秒
let h = parseInt(time / 60 / 60 % 24)
h = h < 10 ? '0' + h : h
let m = parseInt(time / 60 % 60)
m = m < 10 ? '0' + m : m
let s = parseInt(time % 60)
s = s < 10 ? '0' + s : s
this.setData({
h,
m,
s,
duration:this.data.duration - 1
})
if(time > 0){
setTimeout(()=>{
this.getTime()
},1000)
}
},
11-24
08-04
1604
![](https://csdnimg.cn/release/blogv2/dist/pc/img/readCountWhite.png)
01-10