<div class="titme">{{groupHour}}</div>
data(){
return{
groupTime:'',//后台返回数据
groupHour:'',//页面显示数据
}
},
methods: {
getExamTime(){
this.groupTime = 21000 //后台返回数据
this.hours = setInterval(() => {
if (this.groupTime === 0) {
clearInterval(this.hours) // 倒计时结束清除计时器
} else {
this.groupTime-=1;
this.groupMout();
}
}, 1000)
},
groupMout(){
let h = parseInt((this.groupTime / (60 * 60)) % 24);
h = h < 10 ? "0" + h : h;
let m = parseInt((this.groupTime / 60) % 60);
m = m < 10 ? "0" + m : m;
let s = parseInt(this.groupTime % 60);
s = s < 10 ? "0" + s : s;
this.groupHour = h + ":" + m + ":" + s;//页面展示数据
}
}
vue小时倒计时
于 2023-04-06 10:16:34 首次发布