1๐
โ
$route.query
Looks like you are including your parameters as query parameter
, e.g. /?name=xxx&familyname=xxx&gender=xxx
. To get queryparameters from vue route you have to use this.$route.query
.
$route.props
To have props like this.$route.props
, this would require a url like /user/12345/bob
and a vue router setup like
routes: [
{ path: '/user/:id/:name', component: User, props: true }
]
Converting query parameters to vue router props
In the official vue router docs youโll find a very nice example on how to use Function Mode
to convert query parameters to props ( https://router.vuejs.org/guide/essentials/passing-props.html#function-mode ) .
const router = new VueRouter({
routes: [
{ path: '/search',
component: SearchUser,
props: (route) => ({ query: route.query.q })
}
]
})
From the example above the URL /search?q=vue
would pass {query: 'vue'}
as props to the SearchUser
component.
๐คturbopasi
Source:stackexchange.com