Home > Enterprise >  Vue.js - Login Form on submit append Question Mark (?) to the URL
Vue.js - Login Form on submit append Question Mark (?) to the URL

Time:04-28

My login form behavior weird lately. I started off with http://app.test/#/

When I login, rather than login me in, redirect me to : http://app.test/?#/

Only when I clicked login here, then, I will be able to login.

What caused that extra redirect with ? ? Is this something that Vue.js added ? Or something I need to fix on the web server level ?

<v-form ref="form" v-model="valid" lazy-validation  v-on:keyup.enter="onEnterClick">
    <v-text-field  v-model="email" :rules="emailRules" label="Email" required></v-text-field>
    <v-text-field
        :append-icon="show1 ? 'mdi-eye' : 'mdi-eye-off'"
        @click:append="show1 = !show1"
        :type="show1 ? 'text' : 'password'"
        
        v-model="password"
        :rules="passwordRules"
        label="Password"
        required
    ></v-text-field>
    <v-btn type="submit" block :disabled="!valid" color="info"  @click="validate"> Continue </v-btn>

    <router-link to="/forgot-password">
        <button >Forgot Password?</button>
    </router-link>
</v-form>

CodePudding user response:

That's probably being caused by submitting the form and have either no action attribute, or an empty one (because it's not needed in this case since the login will take place using an AJAX call).

You can add the prevent modifier to the form submit handler (assuming that you have one), like so: <form @submit.prevent="myLoginFunction">. That should stop it from doing that.

  • Related