const resdata = reactive({ data: null, stoptime: 0, opentime: 0, info: null, lastLotto: null, record: null, nextGame: null });

const getHaed = async (val) => { const data = { g: val, }; try { const res = await $API.game.index.head.get(data); if (res.code === 0) { const { info, lastLotto, record, nextGame } = res.data; const timeA = new Date(nextGame.now).getTime(); const timeB = new Date(nextGame.stoptime).getTime(); const timeC = new Date(nextGame.opentime).getTime();

  resdata.stoptime = (timeB - timeA) / 1000;
  resdata.opentime = (timeC - timeA) / 1000;
  daojishi();
  clearInterval(timer.value); //清除定时器
  timer.value = setInterval(daojishi, 1000);
}

} catch (error) { console.error(error); } };

JavaScript 异步请求 & 倒计时功能代码优化

原文地址: https://www.cveoy.top/t/topic/lB9r 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录