Access to script at 'file:///D:/hehai/viteObj/dist/assets/index.559fd86e.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.
Vite 为没有传统模块系统设计,模块是其特性推荐。或者,你可以在应用内部署一个自定义方案来使用这个嵌入页面(example-app://什么的),这样可以正常激活 ES Modules 特性,从规避问题开始。解决方法一:在VScode内安装Live Server插件
配置 vite.config.ts
打包好html.index后点击VSode 下的Go Live启动服务