Skip to content

Commit a7b08ca

Browse files
committed
[skip ci] docs: show how to use history mode in electron:build
1 parent 5bf4771 commit a7b08ca

File tree

1 file changed

+13
-8
lines changed

1 file changed

+13
-8
lines changed

docs/guide/commonIssues.md

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,18 +6,23 @@ sidebarDepth: 2
66

77
## Blank screen on builds, but works fine on serve
88

9-
This issue is likely caused when vue-router is operating in `history` mode. Disable history mode like so:
9+
This issue is likely caused when vue-router is operating in `history` mode. To fix this, add a `mounted` hook to the root Vue component:
1010

1111
```javascript
12-
// src/router.js or src/router/index.js
13-
// ...
14-
export default new Router({
15-
mode: 'hash' // instead of "mode: 'history'"
16-
// ...
17-
})
18-
// ...
12+
// src/main.js
13+
14+
new Vue({
15+
router,
16+
render: h => h(App),
17+
mounted() {
18+
// Prevent blank screen in Electron builds
19+
this.$router.push('/')
20+
}
21+
}).$mount('#app')
1922
```
2023

24+
This will fix the Electron build issues, but won't affect web builds.
25+
2126
## `electron:serve` freezes on `Launching Electron...`
2227

2328
Often this issue is caused when Vue Devtools fails to install. This may happen if Vue Devtools cannot be accessed in your location (eg. China). To fix this, you may have to disable Vue Devtools by removing the following lines from your `src/background.(js|ts)` file:

0 commit comments

Comments
 (0)