Sometimes, we want to get current route name in Nuxt.js.
In this article, we’ll look at how to get current route name in Nuxt.js.
How to get current route name in Nuxt.js?
To get current route name in Nuxt.js, we can use the this.$route.name property.
For instance, we write
<script>
//...
export default {
//...
methods: {
get() {
console.log(this.$route.name);
},
},
//...
};
</script>
to log the name of the current route by logging the value of this.$route.name in the get method.
Conclusion
To get current route name in Nuxt.js, we can use the this.$route.name property.