1. btn 定义为一个合法的 DOM 元素,例如通过 document.getElementById("btn") 或者 document.querySelector("#btn") 获取。
  2. testFunction() 改为正确的函数名或者删除这行代码。
  3. await 语句用在 async 函数内部,或者将整个代码片段用 async 函数包裹起来。

修复后的代码如下:

const btn = document.getElementById("btn");
btn.style.display = "none";
setTimeout(() => {
  window.location.reload(true);
}, 2000);
btn.style.display = setTimeout(resolve, 2000)); //6000毫秒后执行testFunction() window.location.reload(true) 修复错误" title="btn.style.display = "none"; await new Promise(resolve => setTimeout(resolve, 2000)); //6000毫秒后执行testFunction() window.location.reload(true) 修复错误" loading="lazy">

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

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