当我尝试使用下面的代码动态导入JS模块时"Uncaught SyntaxError: unexpected reserved word"
,同时进入Firefox和Chrome浏览器,但根据MDN,它应该可以工作。
let module = await import('/modules/my-module.js');
当我使用.then()
而不是时await
,一切正常。MDN错误吗?
您应该在此函数声明中编写“异步”
const my_func = async (arg1,arg2) => {
let module = await import('/modules/my-module.js');
}
https://developer.mozilla.org/zh-CN/docs/Web/JavaScript/Reference/Statements/async_function
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句