Skip to content

Commit ef03755

Browse files
committed
docs(guide/commonIssues): update router mode faq
1 parent db8a50e commit ef03755

File tree

1 file changed

+12
-14
lines changed

1 file changed

+12
-14
lines changed

docs/guide/commonIssues.md

Lines changed: 12 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -6,22 +6,20 @@ 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. To fix this, add a `mounted` hook to the root Vue component:
10-
11-
```javascript
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')
9+
This issue is likely caused when Vue Router is operating in `history` mode. In Electron, it only works in `hash` mode. To fix this, edit your `src/router.(js|ts)`:
10+
11+
```diff
12+
// src/router.(js|ts)
13+
...
14+
export default new Router({
15+
- mode: 'history',
16+
+ mode: process.env.IS_ELECTRON ? 'hash' : 'history',
17+
...
18+
})
19+
...
2220
```
2321

24-
This will fix the Electron build issues, but won't affect web builds.
22+
This will have the router operate in hash mode in Electron builds, but won't affect web builds.
2523

2624
## `electron:serve` freezes on `Launching Electron...`
2725

0 commit comments

Comments
 (0)