// 倒计时 countFun(){ let ts = 100 - 1; // 剩余时间 let countInterval = setInterval(() => { let dd = parseInt(ts / 60 / 60 / 24, 10); // 计算剩余的天数 let hh = parseInt(ts / 60 / 60 % 24, 10); // 计算剩余的小时数 let mm = parseInt(ts / 60 % 60, 10); // 计算剩余的分钟数 let ss = parseInt(ts % 60, 10); // 计算剩余的秒数 dd = this.checkTime(dd); hh = this.checkTime(hh); mm = this.checkTime(mm); ss = this.checkTime(ss); if(ts > 0){ this.countNum.dd = dd; //天 this.countNum.hh = hh; //时 this.countNum.mm = mm; //分 this.countNum.ss = ss; //秒 ts -= 1; }else if(ts <= 0){ this.countNum = { dd: '00', hh: '00', mm: '00', ss: '00' } clearInterval(countInterval); } },1000); }, checkTime(i){ if (i < 10) { i = "0" + i; } return i; }