0👍
When you’r on the /network-error
route, the app is above that, so you can’t say in the app where are you in my app ?
Because your application at this time created
and mounted
the view app and after go inside the route detected.
The good and normal practice is to fetch every route before like a middleware, inside your router.js
or routes/index.js
use this function:
router.beforeEach(async (to, from, next) => {
if (to.name === 'BlackHole') {
next({ name: 'NetworkError' })
}
next()
})
This maybe doesn’t not exactly match your redirect because i miss some information, but i think you understand what you have to do.
- [Vuejs]-Submit event should be emitted when submitting form
- [Vuejs]-VS Code not providing Auto completion for linked scripts
0👍
The problem was because the route load is an async process, I found a very quick solution here, just add this line of config to main.js:
router.isReady().then(() => {app.mount('#app')})
https://www.youtube.com/watch?v=a6gT6qHtch8&ab_channel=VueMastery
- [Vuejs]-Vuejs_ object returns empty in if condition
- [Vuejs]-Why doesn't the post method work in my Vue.js Project?
Source:stackexchange.com