【已解决】 Uncaught SyntaxError: Cannot use import statement outside a module
七娃博客
1,957人阅读
在用ES6的 import引入模块时,控制台显示错误:Uncaught SyntaxError: Cannot use import statement outside a module
从报错信息中获知:无法在模块外部使用 import语句。
模块化(Module)的加载是用 ES6语法实现的,HTML网页引用时,需要在 script标签内加入 type="module"属性。
在<script> 标签内添加 type="module" 属性。
<script type="module" src="./js/index.js"></script>
主题开源不易,支持一下作者吧!
使用支付宝打赏
使用微信打赏
评论 | 0 条评论
登录之后才可留言,前往登录