useRoute / useRouter return undefined instead of current route / router #2094
Replies: 1 comment
-
<script setup lang="ts">
import { RouteNames } from '@/types/router';
import { computed } from 'vue';
import { useRoute } from 'vue-router';
const route = useRoute();
const appBarIcon = computed(() =>
route.name === RouteNames.Home ? 'mdi-account' : 'mdi-home'
);
const routerLinkName = computed(() =>
route.name === RouteNames.Home ? RouteNames.Profile : RouteNames.Home
);
</script>
<template>
<v-app-bar>
<!-- <v-app-bar-title>{{ { appBarIcon, routerLinkName } }}</v-app-bar-title> -->
<template v-slot:append>
<router-link
:to="{
name: routerLinkName,
}"
>
<v-app-bar-nav-icon :icon="appBarIcon"></v-app-bar-nav-icon>
</router-link>
</template>
</v-app-bar>
</template> |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Hey there, im trying to get route in my vue component but useRoute function return undefined
Here is my component
My routes :
My Router :
My app :
Beta Was this translation helpful? Give feedback.
All reactions