suppose there is a method to get data in methods
getData
the data parameter returned by receiving is resultData
mounted
// this
this.getData().then(response => {
let result = response.data
// this
this.resultData = result
})
my question is whether the this outside points to the same as the this inside.
when debugging, sometimes the this
in the then
method is undefined
, and sometimes it is consistent with the outside this, both vuecomponent
. And even if the this
is undefined
, the value of resultData
will be displayed on the page
arrow function is lexical scope, which is determined by the context, so theoretically, the this in is consistent with the this outside ? But why does something different happen?
if you know the answer, look forward to your answer ~ thank you.