problem description:
encapsulates the callback when the axios method, getAxios () is successful
Why does the result appear in the following code
my idea:
1. () = > {} is equivalent to function () {} .bind (this)
2. In strict mode, the this in a function without a direct caller is undefined
himself vaguely aware of the reason, but not sure, hoping to get a clear answer.
created () {
this.getBannerList()
},
methods: {
getBannerList () {
getAxios("/bannerApi", (res) => {
console.log(this) //:VueComponent
})
getAxios("/bannerApi", function (res) {
console.log(this) //: undefined
})
}
}