mounted() {
axios.get('https://')
.then(function(res){
this.spots = res.data;
console.log(this); // undefined
})
}
mounted() {
axios.get('https://')
.then((res) => {
this.spots = res.data;
console.log(this); // Vue
})
}
參考來源:
https://iter01.com/141625.html
https://blog.scottchayaa.com/post/2019/03/09/jquery-closure-function-this/