diff --git a/src/views/oneMap/components/ZHRQ.vue b/src/views/oneMap/components/ZHRQ.vue index 1ddb597..689130e 100644 --- a/src/views/oneMap/components/ZHRQ.vue +++ b/src/views/oneMap/components/ZHRQ.vue @@ -439,7 +439,7 @@ }); // 获取要显示倒计时的HTML元素 -const timerElement = document.getElementById('timer'); +const intervalId = ref(null); function runTime() { const futureTime2 = new Date(AllData.showTipsData.warnStartTime).getTime(); //开始时间 const currentTime = new Date().getTime(); @@ -452,10 +452,10 @@ const seconds = Math.floor((timeDifference % (1000 * 60)) / 1000); // console.log(`剩余时间: ${days}天 ${hours}小时 ${minutes}分钟 ${seconds}秒`); // 每秒更新一次倒计时 - const intervalId = setInterval(runTime, 1000); + intervalId.value = setInterval(runTime, 1000); // 检查倒计时是否结束 if (timeDifference <= 0) { - clearInterval(intervalId); // 清除定时器 + clearInterval(intervalId.value); // 清除定时器 showTips.value = false; } else { // 更新HTML元素的内容 hoursQ