Reputation: 1326
I have following component for the url:
{
path: '/resetpassword',
name: 'view-resetpassword',
component: ViewResetPassword,
},
And it gets opened when I enter localhosst:8080/resetpassword
My question is how to access parameters that are given in that way:
localhost:8080/resetpassword/53c957fe-bbc2-4b32-8ebd-a84d79f7ffd2
I know, that I can access URL paramaters ?key=value
with this.$route.query.key
in the code. But how do I access parameter /...
?
Upvotes: 0
Views: 448
Reputation: 6853
Set your router to:
{
path: '/resetpassword/:token?',
name: 'view-resetpassword',
component: ViewResetPassword,
},
That route now can have optional token
param (?
is for the optional).
Then you can access it on your component
this.$route.params.token
You can also pass it as a props instead, by adding props: true
on the router
{
path: '/resetpassword/:token?',
name: 'view-resetpassword',
component: ViewResetPassword,
props: true
},
and on your component
export default {
...
props: ["token"];
...
}
then you can access the props
this.token
Upvotes: 1