Typescript this类成员无法在axios里面赋值

class App {
app: Application

constructor() {
this.app = new Application();
axios.get(…).then(res => {
this.app.currentUser = res.data.data; // currentUser?: UserModel
});
}
}

在then里面this.app.currentUser赋值成功,但是返回之后this.app.CurrentUser为undefined,什么情况?

阅读 1.7k
撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进