一、 ES Module 规范特性
通过给 script 添加 type = module 的属性,就可以以 ES Module 的标准执行其中的 JS 代码
<script type='module'></script>
- ESM 自动采用严格模式,相当于在代码添加
‘use strict’
。
注意,在严格模式下,this是 undefined;非严格模式this是window。
- 每个 ES Module 都是运行在单独的私有作用域中,外部无法访问内部的成员。
<script type='module'>
var foo = 100
</script>
<script type=