我有这样的数据:
data: () => ({
input: {
username: "",
password: ""
}
}),
并发出这样的帖子请求:
loggin_in() {
if (this.input.username != "" && this.input.password != "") {
console.log(this.input.username);
axios
.post("http://localhost:5000/login", {
email: this.input.username,
password: this.input.password
})
.then(function(data) {
console.log(data);
})
.catch(function(error) {
console.log(this.input.username);
});
}
}
记录第一个this.input.username作品,但在那之后,我不知道如何访问数据。this似乎是未定义的。
Uncaught (in promise) TypeError: Cannot read property 'input' of undefined
我不知道为什么this这里的上下文发生了变化,也不知道如何访问我的数据。任何人都可以向我解释发生了什么并帮助我解决这个问题吗?