[Vuejs]-Cannot access data from methods in Vue.js

5👍

Your main issue lies with this line:

sendEmail: (e) => {

VueJS documentation explicit states that you should not use arrow functions when declaring methods, because the this inside the methods will not refer to the VueJS component itself.

Note that you should not use an arrow function to define a method (e.g. plus: () => this.a++). The reason is arrow functions bind the parent context, so this will not be the Vue instance as you expect and this.a will be undefined.

Therefore, this will fix your issue:

sendEmail: function(e) {

or:

sendEmail(e) {
👤Terry

Leave a comment