Skip to content Skip to sidebar Skip to footer

Accessing $route.params In Vuejs

Looking through this documentation: https://router.vuejs.org/en/essentials/navigation.html It looks like you can bind the Link Text

Solution 1:

If you're using the Vue Loader setup (which has <template></template> tags in the files), you need to use this to reference the $router, if you're doing so within the <script></script> part of the file.

 console.log('The id is: ' + this.$route.params.id);

Solution 2:

For and one wanting to get params in vue 3 with composition API for vue-router 4.x, it can be achieved using useRoute.

import {useRoute} from"vue-router";
setup(){
   const route = useRoute();
   const id = route.params.id;
} 

Post a Comment for "Accessing $route.params In Vuejs"