let num=6; let interval=setInterval (function () { num-=1; console.log(num) if(num<=1){ clearInterval(interval) } }, 1000); var countTime=function(lefttime){ var leftm = Math.floor(lefttime/(1000*60)%60); //计算分钟数 var lefts = Math.floor(lefttime/1000%60); //计算秒数 if(leftm<10){ if(lefts<10){ return "0"+ leftm + ":" + "0"+lefts; }else{ return "0"+ leftm + ":" + lefts; } }else{ if(lefts<10){ return leftm + ":" + "0"+lefts; }else{ return leftm + ":" + lefts; } } }