Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Help] build后应用白屏 #229

Closed
lee-holden opened this issue Aug 9, 2022 · 9 comments · Fixed by electron-vite/vite-plugin-electron#54
Closed

[Help] build后应用白屏 #229

lee-holden opened this issue Aug 9, 2022 · 9 comments · Fixed by electron-vite/vite-plugin-electron#54
Labels
help wanted Extra attention is needed

Comments

@lee-holden
Copy link

Describe the problem you confuse

history模式白屏无报错,hash白屏报错如下,怎么解决?
image

@lee-holden lee-holden added the help wanted Extra attention is needed label Aug 9, 2022
@lee-holden
Copy link
Author

DataExchange是路由‘/’的组件

@caoxiemeihao
Copy link
Member

给下 Demo

@lee-holden
Copy link
Author

路径和组件名字没出错,只有一个组件,在dev下正常显示,在build后打开应用出现上述问题。
image

@caoxiemeihao
Copy link
Member

推个仓库到 github 上来可好?

@HaoAu3
Copy link

HaoAu3 commented Aug 10, 2022

同样报了类似的错

Error: Cannot find module './home.af855b02.js'
Require stack:

  • C:\Users\Administrator\AppData\Local\Programs\electron-vue-vite\resources\app.asar\dist\index.html
    at Module._resolveFilename (node:internal/modules/cjs/loader:940:15)
    at i._resolveFilename (node:electron/js2c/renderer_init:33:1095)
    at Module._load (node:internal/modules/cjs/loader:785:27)
    at c._load (node:electron/js2c/asar_bundle:5:13343)
    at i._load (node:electron/js2c/renderer_init:33:356)
    at Module.require (node:internal/modules/cjs/loader:1012:19)
    at require (node:internal/modules/cjs/helpers:102:18)
    at index.b8ba64b0.js:12:22647

@lee-holden
Copy link
Author

推个仓库到 github 上来可好?

https://github.com/DDDHL/electron-vite-ts-demo

@HaoAu3
Copy link

HaoAu3 commented Aug 10, 2022

解决了,是vue-router动态加载的问题,
只需要把
router/index.ts中,
component: () => import('@/views/home.vue')

改为
import home from '@/views/home.vue'
component: home

另外,我因为 pinia的缘故,
所以只做了上面的一步还不能解决问题,
第二步是,把main.ts拆分成下面两个文件,
pre.ts
import { createApp } from 'vue'
import App from './App.vue'
// import './samples/node-api'

import { createPinia } from 'pinia'
import 'element-plus/theme-chalk/el-message.css'
import 'element-plus/theme-chalk/el-message-box.css'

export const data = createApp(App).use(createPinia())

main.ts
import { data } from './pre'
import router from './router'
data
.use(router)
.mount('#app')
.$nextTick(() => {
postMessage({ payload: 'removeLoading' }, '*')
})

@caoxiemeihao
Copy link
Member

解决了,是vue-router动态加载的问题,

import('@/views/home.vue') 还是要解决的,很多人喜欢这么写。我下午看一下,感谢你的代码 👍

@caoxiemeihao
Copy link
Member

caoxiemeihao commented Aug 10, 2022

@DDDHL 先按照图片的方式配置下,BUG 我下午会修复
image


0.8.8 已修复

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted Extra attention is needed
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants