【问题标题】:getting error: "Property 'user' does not exist on type 'ArrayBuffer'. in Angular收到错误:“类型'ArrayBuffer'上不存在属性'用户'。在Angular中
【发布时间】:2018-09-19 18:55:21
【问题描述】:

所以我想在 Profile 组件中显示用户信息,但每当我运行服务器时,我都会收到两次相同的消息:“ArrayBuffer”类型上不存在属性“用户”。我试图查找它,但到目前为止我还没有得到任何线索是什么导致了这种情况。任何人都可以帮忙吗? 这是 profile.component.ts:

  username;
email;

constructor(private auth: AuthService) { }

ngOnInit() {
this.auth.getProfile().subscribe(profile => {
  this.username = profile.user.username;
  this.email = profile.user.email;

  })
}

【问题讨论】:

    标签: angular properties arraybuffer


    【解决方案1】:

    尝试将响应更改为 any,在这种情况下,

    this.auth.getProfile().subscribe((profile:any) => {
      this.username = profile.user.username;
      this.email = profile.user.email;
    })
    

    【讨论】:

      猜你喜欢
      • 2019-12-24
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-11-17
      • 1970-01-01
      • 2018-10-04
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多