Categories
Vue Answers

How to get current route name in Nuxt.js?

Spread the love

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.

By John Au-Yeung

Web developer specializing in React, Vue, and front end development.

Leave a Reply

Your email address will not be published. Required fields are marked *