js 实用方法

1、倒计时
const countDown = (second) => { const s = second % 60; const m = Math.floor(second / 60); return ${00${m}.slice(-2)} : ${00${s}.slice(-2)};};let time = 5 * 60;const timer = setInterval(() => { const show = countDown(time--); console.log(show); if(time < 0) { console.log('倒计时结束!'); clearInterval(timer); }}, 1000);

posted @ 2023-02-21 14:56  你说累不累  阅读(11)  评论(0编辑  收藏  举报