考试倒计时

let time = 1200; // 总时间/S

window.paper_timer = setInterval(() => {
// 倒计时
time--;
let hh = Math.floor(time / 3600);
let mm = Math.floor(Math.floor(time % 3600) / 60);
let ss = time % 60;
let h_u = hh > 9 ? hh : '0' + hh;
let m_u = mm > 9 ? mm : '0' + mm;
let s_u = ss > 9 ? ss : '0' + ss;
let val = h + ':' + m + ':' + s;


let use_t;
if(h_u != 0) {
use_t = h_u+'时' + m_u+'分' +s_u+'秒';
}else if(h_u == 0) {
if(m_u != 0) {
use_t = m_u+'分'+s_u+'秒';
}else {
use_t = s_u+'秒';
}
}


}, 1000)

 

 

posted @ 2021-11-05 16:23  S_ayNo  阅读(80)  评论(0编辑  收藏  举报