I am using Nuxt.js, and have a dymanic page which is defined under
pages/post/_slug.vue
So, when I visit the page url, say, http://localhost:3000/post/hello-world, how can I read this slug parameter value inside my page.
Currently I am geting it using asyncData as follows:
asyncData ({ params }) {
// called every time before loading the component
return {
slug: params.slug
}
}
This is working fine, but I think this is not the best way, and there should be a better way to make the parameter available to the page. Any help is appreciated!