起因
开发时需要在静态 h5 页面中引入 js 文件,
<script type="module">
import * as m1 from "./js/m1.js";
console.log(m1);
</script>
而引入后报错
Access to script at 'file:///G:/code/frontend/src/js/m1.js' from origin 'null' has been blocked by CORS policy: Cross origin requests are only supported for protocol schemes: http, data, isolated-app, chrome-extension, chrome, https, chrome-untrusted.
解决
安装插件
右键 open with live server