search

Home  >  Q&A  >  body text

Pass v-model email value to method

Hi, I'm trying to pass v-model on the input to try to send the email to reset the validation, but I don't know how to pass it correctly from the input to sendPasswordResetEmail. This is what I have so far

methods:{
  
      resetPassword(){
          const auth = app.auth();          
          const userEmail = ref('')
          auth.sendPasswordResetEmail(userEmail.value).catch((error) =>  {
              console.log(error);
          });
          alert('Reset email has been sent')
          console.log(userEmail)
          
      },
    },

This is the input part

<form v-if="reset" @submit.prevent="resetPassword">
<input type="email" required placeholder="email" v-model="userEmail" class="inline-block">
<button>Reset Password</button>
 
</form>

I've also been trying to return userEmail, but nothing seems to work.

P粉882357979P粉882357979232 days ago531

reply all(1)I'll reply

  • P粉731861241

    P粉7318612412024-04-06 00:35:28

    Check if you are getting user email value in resetPassword() function. If not, then the problem is with the reference.

    Correct this line,

    const userEmail = ref('')
    

    If you use values ​​from HTML v-model, you must use the this keyword.

    reply
    0
  • Cancelreply