问题: dev 环境使用 url 正常显示,打包后页面空白
// dev
mainWindow.loadURL('http://localhost:8000/')
// prod
mainWindow.loadFile(path.resolve(__dirname, '../renderer', 'index.html'));
原因: history 模式只能部署到 web 服务器使用,默认是 history
解决: 路由使用 hash 模式
// .umirc.ts
export default {
history: { type: 'hash' },
}

在开发环境中使用`http://localhost:8000/`加载页面正常,但打包后出现空白页。问题源于history模式的路由必须依赖web服务器。解决方案是将路由设置为hash模式,通过修改`.umirc.ts`配置文件,将`history.type`设为'hash',确保应用能在非服务器环境下正确运行。
472

被折叠的 条评论
为什么被折叠?



