0👍
✅
asumming you are using vue-router, the route component should be declared so:
routes: [
{ path: '/song/:id', component: Song }
]
then in your created method of Song component can get the id param:
created() {
axios.get('/api/get-song-details/' + this.$route.params.id)
...
}
0👍
All route params can be accessed by using this.$route.params.paramName
in JS code or by using $route.params.paramName
in template. paramName
is the parameter name as defined in your router.
Source:stackexchange.com