To get the current route name in a Vue application using Vue Router.
let obj = {
path: '/about',
name: 'About',
component: About
}
import { useRoute } from 'vue-router'
const route = useRoute()
console.log(route.name)
Use $route.name inside the component context.
export default {
mounted() {
console.log(this.$route.name)
}
}
The route name is useful for navigation, conditionals, analytics, and breadcrumbs.
If name is not defined in the route config, it will return undefined.
Work with our skilled Vue developers to accelerate your project and boost its performance.
Hire Vuejs Developers