报错信息
Access to script at 'file:///E:/qianduan/aaa.js' from origin 'null' has been blocked by CORS policy: Cross origin requests are only supported for protocol schemes: http, data, chrome, chrome-extension, chrome-untrusted, https.
aaa.js:1
Failed to load resource: net::ERR_FAILED
用这个 open in defaule browser (alt+B)在浏览器打开:
分析原因:
由于module引入的方式,会产生跨域请求,本地file协议不支持,无法加载对应js模块。
解决方法:
vscode中安装live Server插件并Open with Live Server运行
我安装的这个
显示无错误