Uncaught SyntaxError: Cannot use import statement outside a module

在普通的js中引入了第三方的js通过(npm):

Uncaught SyntaxError: Cannot use import statement outside a module

但这是es6语法。在报错中了解到,是说无法在模块外部使用import语句,因为Module 的加载实现的是es6语法,所以在浏览器加载html文件时,需要在script 标签中加入type="module"属性。

Uncaught SyntaxError: Cannot use import statement outside a module

Uncaught SyntaxError: Cannot use import statement outside a module

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2021-10-06
  • 2021-05-03
  • 2021-07-20
猜你喜欢
  • 2022-12-23
  • 2021-12-18
  • 2021-11-27
  • 2022-12-23
  • 2021-10-16
  • 2023-02-16
  • 2022-12-23
相关资源
相似解决方案