1๐
โ
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
๐คOwl
1๐
You can use, like this
{ name: 'Projeto', path: '/projeto/:id', component: Projeto, meta: { public: true } }
with the :(the name), in the component:
this.$route.params.id
In my example is id, but you can put another name
A page to example VueRouter
๐คMatheus
1๐
From the docs, proceed as so:
{
path: '/resetpassword/:id', // I changed here
name: 'view-resetpassword',
component: ViewResetPassword,
}
Then in the matched component, you can access the parameter through $route.params.id
.
๐คDev Yego
Source:stackexchange.com