烂笔头开始记录小知识点啦~

  • 浏览器要加载 ES6模块,:
    <script type="module" src="./foo.js"></script>

     

  • 异步加载,相当与defer属性。可以另外设置async属性。
  • ES6 模块也允许内嵌在网页中,语法行为与加载外部脚本完全一致。
    <script type="module">
      import utils from "./utils.js";
    
      // other code
    </script>

     

  • CommonJS 模块输出的是一个值的拷贝,ES6 模块输出的是值的引用。
  • CommonJS 模块是运行时加载,ES6 模块是编译时输出接口。

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2021-07-09
  • 2022-12-23
  • 2018-11-01
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2021-11-22
  • 2021-09-17
  • 2022-03-09
  • 2022-12-23
  • 2021-11-12
  • 2022-12-23
相关资源
相似解决方案