Uncaught SyntaxError: Cannot use import statement outside a module (at import.js:2:1)
时间: 2023-08-25 16:18:56 浏览: 106
回答: 这个错误提示说无法在模块外使用import语句。要解决这个问题,你需要确保在HTML中导入模块的<script>标签的类型(type)已经指定为module,而不是text/javascript。例如,在index.html中的<script type="module">标签中导入模块并使用import语句。通过这种方式,你应该能够解决Uncaught SyntaxError: Cannot use import statement outside a module错误。<span class="em">1</span><span class="em">2</span><span class="em">3</span>
#### 引用[.reference_title]
- *1* *2* [详细分析解决Uncaught SyntaxError: Cannot use import statement outside a module (at ...)的错误](https://blog.csdn.net/lvoelife/article/details/129165308)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v92^chatsearchT0_1"}}] [.reference_item style="max-width: 50%"]
- *3* [Uncaught SyntaxError: Cannot use import statement outside a module](https://blog.csdn.net/Amnesiac666/article/details/129103005)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v92^chatsearchT0_1"}}] [.reference_item style="max-width: 50%"]
[ .reference_list ]
阅读全文