更新时间:2023-01-03 17:27:31
您的 this
指向回调中的错误对象.尝试使用箭头函数,闭包或 bind
.
Your this
is pointing to the wrong object in your callbacks. Try using an arrow function, a closure, or bind
.
这里是使用箭头功能的示例.
Here is an example using an arrow function.
axios.get('/config/database')
.then(response => {
this.databaseConfiguration = response.data;
console.log(response.data);
})
.catch(error =>{
this.errors.push(error);
console.log(error);
})
See How to access the correct this
inside a callback.