【发布时间】:2022-03-30 23:47:26
【问题描述】:
我很困惑,因为我读到 ESM 支持顶级等待,但是当我在 html 文件中尝试它时它不起作用?
如果我发现这是说: Top-level await does not work with node 14.13.- “顶级等待仅适用于 ESM 模块”
ESM 是否支持顶级 await 以及如何使用它。
document.getElementById('foo').innerHTML = 'hello1';
await pause(2000); // is this possible if so how
document.getElementById('foo').innerHTML = 'hello2';
【问题讨论】:
标签: javascript async-await es6-modules top-level-await