Categories
Vue Answers

How to get route URL parameters in a page with Nuxt.js?

Spread the love

Sometimes, we want to get route URL parameters in a page with Nuxt.js.

In this article, we’ll look at how to get route URL parameters in a page with Nuxt.js.

How to get route URL parameters in a page with Nuxt.js?

To get route URL parameters in a page with Nuxt.js, we can get them from the this.$route.params object.

For instance, we write

<script>
//...
export default {
  //...
  mounted() {
    console.log(this.$route.params.slug);
  },
  //...
};
</script>

to get the value of the slug URL parameter with this.$route.params.slug).

Conclusion

To get route URL parameters in a page with Nuxt.js, we can get them from the this.$route.params object.

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 *