I'm building an app using vue and vue-router. I've created a Login component with the usual fields for email and password, and a forgot password router-link. What I wanted to do was to pass the email from the email field if the user has typed it in already but then clicked on the forgot password button. This is how the user gets transferred to the resetPassword component:
<router-link :to="{ name: 'resetPassword', query: { email } }">
Forgot password
</router-link>
and this is how I handle the route within the router:
{
path: '/resetpassword/:email?',
name: 'resetPassword',
component: require('../components/ResetPassword').default,
props: route => ({ email: route.query.email }),
},
this solution works but my only issue is that if the user hasn't typed in an email I will get an url that will look like this:
localhost:8080/resetpassword?email=
while I want it to look like this:
localhost:8080/resetpassword
how can I omit the empty email query parameter? Do I have to do something in the config of vue-router? I couldn't find something about this in the documentation.
vuexto hold the email and read it from the store inforgot_passwordview.