Vite + Vue3 + Electron 打包后静态资源路径错误?-灵析社区

金刚老六

Vite + Vue3 + Electron 打包后静态资源路径错误 图片 src 如果是动态拼接的话,路径指向会出现问题 import { ref } from "vue"; const filename = ref("vite.svg"); ![2024-03-15_11-17-27.png](https://wmprod.oss-cn-shanghai.aliyuncs.com/c/user/20241006/49e0597451563deb86970a992981baa8.png) 第一个路径不正确:file:///G:/vite.svg 第二个路径为:file:///G:/vite-electron/release/win-unpacked/resources/app.asar/dist/vite.svg @font-face { font-family: HanYiQiHei; src: url('/fonts/HanYiQiHei.ttf'); } 还有这种字体文件导入也会出现问题,类似上面直接从 G 盘读取 有没有什么好的解决方案?

阅读量:161

点赞量:0

问AI
办公室高手
const modules = import.meta.glob('./image/*.svg', { eager: true, import: 'default' }) const fileName = ref('xx.svg')