// 倒计时countTime(){// 获取当前时间let date =newDate()let now = date.getTime()// 设置截止时间let endDate =newDate(this.curStartTime)// this.curStartTime需要倒计时的日期let end = endDate.getTime()// 时间差let leftTime = end - now
// 定义变量 d,h,m,s保存倒计时的时间if(leftTime >=0){// 天this.day = Math.floor(leftTime /1000/60/60/24)// 时let h = Math.floor(leftTime /1000/60/60%24)this.hour = h <10?'0'+ h : h
// 分let m = Math.floor(leftTime /1000/60%60)this.min = m <10?'0'+ m : m
// 秒let s = Math.floor(leftTime /1000%60)this.second = s <10?'0'+ s : s
}else{this.day =0this.hour ='00'this.min ='00'this.second ='00'}// 等于0的时候不调用if(Number(this.hour)===0&&Number(this.day)===0&&Number(this.min)===0&&Number(this.second)===0){return}else{// 递归每秒调用countTime方法,显示动态时间效果,setTimeout(this.countTime,1000)}},