新的 ECMAScript 6 import
和 export
是异步的吗?我找到了这个:
http://exploringjs.com/es6/ch_modules.html
16.2.2 ECMAScript 6 modules
The goal for ECMAScript 6 modules was to create a format that both users of CommonJS and of AMD are happy with:
- Similarly to CommonJS, they have a compact syntax, a preference for single exports and support for cyclic dependencies.
- Similarly to AMD, they have direct support for asynchronous loading and configurable module loading.
这是否意味着如果我有类似的东西
import * from A
import * from B
alert(1);
然后它同时下载 A 和 B,然后在两者都加载时 alert
?
最佳答案
不,他们不是。模块是声明性的,静态指定要导入和导出的什么。
它们没有指定如何导入,那是模块加载器的工作。不同的加载器可能表现不同,有些是同步的,有些是异步的。
关于javascript - 新的 ECMAScript 6 导入和导出是异步的吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41706953/