解决普通js文件使用import js模块报错

676 阅读1分钟

今天用原生js写,想要引入另一个js文件的函数,结果报错

 "Uncaught SyntaxError: Cannot use import statement outside a module" when importing ECMAScript 6

解决方法:

sciprt标签加上module

 <script type="module" src="milsymbol-2.0.0/src/milsymbol.js"></script>

stackoverflow.com/questions/5…