不使用构建工具,本地app能用importmap吗 #13786
Replies: 1 comment
-
Hi @stirwl, Most likely you're opening the HTML file directly from your folder, right? So the URL starts with Browsers have this security thing where they block module scripts loaded that way, because there's no server to tell them it's a real JavaScript file (that's the MIME type error you're seeing). Easiest fix is to run a simple local server. You don't need any build tools. Since you're working with JS, you probably have Node.js/npm installed. Just open a terminal in your project folder and run:
It will start a server and give you a URL like The "Live Server" extension in VS Code is also a super easy way to do this if you use that editor. Hope that helps |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
因为vue示例大多使用import方式,所以我也想用这种方式
<script type="importmap"> { "imports": { "vue": "./vue.esm-browser.js" } } </script>但importmap不能导入本地文件。
Failed to load module script: Expected a JavaScript-or-Wasm module script but the server responded with a MIME type of "". Strict MIME type checking is enforced for module scripts per HTML spec.
Beta Was this translation helpful? Give feedback.
All reactions