Axios and VueJS, function(response) is not setting a list

后端 未结 1 409
孤独总比滥情好
孤独总比滥情好 2020-12-02 02:46

I have an request to get some data and add it to a variable,

When I use:

.then(function(response) {
    this.persons = response.data;
});

相关标签:
1条回答
  • 2020-12-02 03:01

    As I have explained it here, arrow syntax does not bind it's own this, arguments, super, or new.target. Arrow functions are always anonymous. These function expressions are best suited for non-method functions.

    Scope of this changes inside a function() block and it does not refer to the currently executing function, while with arrow function, this refers to the currently executing function only.

    0 讨论(0)
提交回复
热议问题