Skip to content

Commit

Permalink
分离importmap到importmap.js,并用text/javascript类型加载。
Browse files Browse the repository at this point in the history
使用“module”加载时会“External import maps”错误

@see WICG/import-maps#235

@see https://www.jianshu.com/p/b23d823a183a
  • Loading branch information
SunDawning committed Mar 28, 2022
1 parent 52426a2 commit c43fc59
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,7 @@
<head>
<meta charset="utf-8" />
<title>清空绘图区</title>
<script type="importmap">
{
"imports": {
"Canvas": "./Canvas.js"
}
}
</script>
<script type="text/javascript" src="./importmap.js"></script>
<script type="module">
{
const { Canvas } = await import("Canvas");
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
const script = document.createElement("script");
script.type = "importmap";
script.textContent = JSON.stringify({
imports: {
Canvas: "./Canvas.js",
},
});
document.currentScript.after(script);

0 comments on commit c43fc59

Please sign in to comment.