根据后端返回的时间戳 来进行倒计时
作者:互联网
timer() {
this.time 为后端返回的时间戳
this.m = parseInt((this.time % (1000 * 60 * 60)) / (1000 * 60));
this.s = parseInt((this.time % (1000 * 60)) / 1000);
const times = setInterval(() => {
this.s--;
if (this.s < 10) this.s = `0${this.s}`;
if (this.s === "00") {
this.s = 59;
this.m--;
if (this.m < 10) this.m = `0${this.m}`;
if (this.m === "00" && this.s === "00") clearTimeout(times);
}
}, 1000);
},
标签:返回,60,00,根据,10,times,倒计时,time,1000 来源: https://blog.csdn.net/shuaigie/article/details/121954189