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, }; const res = await $API.game.index.head.get(data); if (res.code === 0) { const { info, lastLotto, record, nextGame } = res.data; resdata.info = info; resdata.lastLotto = lastLotto; resdata.record = record; resdata.nextGame = nextGame; // 是否应该是nextGame?

const timeA = new Date(resdata.nextGame.now).getTime(); // 优化此处的代码,使用resdata.nextGame
const timeB = new Date(resdata.nextGame.stoptime).getTime();
const timeC = new Date(resdata.nextGame.opentime).getTime();

resdata.stoptime = (timeB - timeA) / 1000;
resdata.opentime = (timeC - timeA) / 1000;
daojishi();

clearInterval(timer.value);
timer.value = setInterval(daojishi, 1000);

} };

JavaScript 获取游戏数据并计算倒计时

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

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