如果我拥有以下内容:
<script type="module" src="one.js"></script>
<script type="module" src="two.js"></script>
<script type="module" src="three.js"></script>
- 我说你不能百分之百确定
three.js
会在one.js
和two.js
后执行,我的说法正确吗?
但是,如果我有以下代码:
<script type="module">
import 'one.js'
import 'two.js'
import 'three.js'
</script>
- 我说的对吗,
three.js
会在one.js
和two.js
之后执行,我可以很有信心吗?(这很重要)
可能的重复问题评论
我知道这看起来像一个重复的问题,但请记住,这个问题的目的是确认通过HTML和JavaScript导入的非常不同的行为。
three
在one
和two
之后执行,那么将这两个导入到three
中(避免循环依赖)。不要依赖于主模块中的导入顺序。 - Bergiawait
打破了模块按导入顺序执行的假设。 - Bergi