#public asset

10 messages · Page 1 of 1 (latest)

slate mountain
#

v-on:submit.prevent="login()" on form with v-model="userForm.username" and v-model="userForm.password"
I can click or press enter one time, eg: wrong username, then every keypress trigger the function why ?

#

How to prevent that ?
I use <script setup> with :
const userForm = ref({
username: "",
password: "",
});

severe viper
#

Most likely because you’re invoking login() rather than passing it by assignment. So every time the input changes, the form re-renders and the function is invoked. Try @submit.prevent="login" or @submit.prevent="() => login()"

slate mountain
limber pivot
#

In login, you probably use useFetch

#

Instead you want to use $fetch

slate mountain
#

@limber pivot why ?

#

(yes I use useFetch)

limber pivot
#

because useFetch is reactive, so when the ref change, the request will be triggered again

#

$fetch not