Answer the question
In order to leave comments, you need to log in
How to call a function that changes data from a component's event?
https://jsfiddle.net/d918pasu/
the first button changes the data directly in the attribute (it works), the second one in the handler function (documentation ) and it doesn't work.
why inside increment as this is the window object and how to change the example so that you can change the data in the handler?
Answer the question
In order to leave comments, you need to log in
You are using an arrow function, it takes this from the lexical environment. You need it like this:
increment: function(num) {
console.log(num, this);
this.counter += num;
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question