【发布时间】:2021-11-18 11:14:42
【问题描述】:
为什么第 3 行打破了这个例子?注释掉第 3 行后效果很好。
<button id="button">Click me</button>
<script type="module">
import { foo } from "script.js"; // BREAKS THINGS
document.getElementById("button")
.addEventListener("click",
function(){ alert("hello") } );
</script>
在 MS Edge 93 中测试。
【问题讨论】:
-
你得到什么错误?
-
我在浏览器中测试时没有任何反馈
-
你打开了控制台?
-
哦,我不敢相信我不知道在控制台上看到错误,谢谢!
标签: javascript html import