0👍
You can try putting router-view
in App.vue
<template>
<v-app>
<v-navigation-drawer v-if="isLoggedIn">
...
</v-navigation-drawer>
<v-content>
<router-view></router-view>
</v-content>
</v-app>
</template>
<script>
export default {
mounted () {
if (this.isLoggedIn) {
// this is better to have guard in router
// https://router.vuejs.org/guide/advanced/navigation-guards.html#global-before-guards
this.$router.push('/login')
}
},
}
</script>
Note:
- You don’t need to import Login into App.vue. You should use router-view to render it.
- The router guard is better doing in another place, like router/index.js. You can find an example here
- [Vuejs]-How to call/initlialize a vue method from outside of the Vue APP
- [Vuejs]-How do i get specific value from a json data (api) using axios in vue
Source:stackexchange.com