[Vuejs]-TypeError with Vuejs Emailjs Vee-validate : Cannot read property 'target' of undefined

0👍

handleSubmit does not pass the event argument to the given callback, so e is undefined.

Instead of e.target (which would be the form element if the event were passed), you could reference the form directly with a template ref:

<form ref="myForm">
export default {
  methods: {
    sendEmail() {
      try {
        emailjs.sendForm(
          'service_xxx',
          'template_xxx',
          this.$refs.myForm, 👈
          'user_xxx',
          {
            name: this.name,
            email: this.email,
            message: this.message,
          }
        )
      } catch (error) {
        console.log({ error })
      }
    }
  }
}

Leave a comment