vue验证码倒计时60s

vue3验证码倒计时60s

//倒计时60s

const timeNum = ref(60);
const countDown = ref();
const isShowSend = ref(true);


    const getSetInterval = (): void => {
      countDown.value = setInterval(() => {
        setTimeout(() => {
          if (timeNum.value > 0 && timeNum.value <= 60) {
            isShowSend.value = false;
            timeNum.value--;
          } else {
            isShowSend.value = true;
            clearInterval(countDown.value);
          }
        }, 0);
      }, 1000);
    };

return {
      isShowSend,
      timeNum,
      countDown,
}

 

posted @ 2022-03-14 17:49  挥不去的执念  阅读(956)  评论(0编辑  收藏  举报