Hey there, I've been working on passing props in Vue routes and have made some progress but it's not quite what I want.
What I have so far
route.js
{
path: '/register/',
name: 'register',
component: require('./views/Login').default,
}
home.vue
<router-link tag="li" :to="{ name: 'register', params: { isRegisteringMe: 'true' }}" class="btn btn-green m-top-20 menu-btn" v-show="!isLoggedIn">Register</router-link>
In register.vue, I can check
console.log(this.$route.params.isRegisteringMe);
which will return true
when I click on the Register link.
However, if a user types in the URL directly as website.com/register
, this method won't work. I've tried various methods like the ones below with no luck:
{
path: '/register/:id',
name: 'register',
props: { isRegisteringMe: 'hi props'},
component: require('./views/Login').default,
}
Or
{
path: '/register',
name: 'register',
props: { isRegisteringMe: 'hi'},
params: { isRegisteringMe: 'hi'},
component: require('./views/Login').default,
}
I've experimented with different combinations but I'm still struggling to find a solution.