微信小程序 倒计时

let that = this;
let startTime = xxx.startTime;
let u = setInterval(()=>{
    let nowTime = new Date().getTime()
    let djs = startTime-nowTime;   
    if(djs<=0){
     clearInterval(u)
    }
    let   d = Math.floor(djs/1000/60/60/24); //天
    let  h = Math.floor(djs/1000/60/60%24); //时
    let m = Math.floor(djs/1000/60%60); //秒
    let s = Math.floor(djs/1000%60);//分
    let dh = h+d*24
    if(dh<10){
        dh='0'+dh.toString();
    }
    if(m<10){
            m='0'+m.toString();
     }
    if(s<10){
            s='0'+s.toString();
     } 
    that.setData({
            h:dh,
            m,
            s,
          })
},1000)

你可能感兴趣的:(微信小程序 倒计时)