0👍
Solved for now attaching the global property to the router instance instead of the Vue instance:
Vue.use(Router)
// global status property
Router.prototype.$isAppInitialized = false
const router = new Router({
routes: routes
})
router.beforeEach((to, from, next) => {
if (to.path !== "/" && !router.$isAppInitialized) {
next("/")
}
else {
next()
}
})
This works because it is possible to access the router instance in the components and update the global property, but feels like an hack to me. Please let me know if there better ways to do this.
- [Vuejs]-Passing foreach loop item from blade to vue and getting each of the looped item
- [Vuejs]-Does google recaptcha 3 on vuetify really not appear? automatic?
Source:stackexchange.com