Php 如何在IONIC 4中显示数据

Php 如何在IONIC 4中显示数据,php,ionic-framework,Php,Ionic Framework,开发人员下午好,我已经从我的api获取了数据,数据响应如下 {id: 1, owner: "2", amount: "0", created_at: "2020-09-14 11:04:12", updated_at: "2020-09-14 11:04:12"} 下面是我的代码 return this.http.post(this.env.API_URL + "auth/wallet", {

开发人员下午好,我已经从我的api获取了数据,数据响应如下

{id: 1, owner: "2", amount: "0", created_at: "2020-09-14 11:04:12", updated_at: "2020-09-14 11:04:12"}
下面是我的代码

return this.http.post(this.env.API_URL + "auth/wallet", {
        id: this.user['id'],
      }).subscribe(res => {
        this.wallet = res[0];
        console.log(this.wallet);
      }, (err) => {
          console.log(err);
      });

当我键入{wallet[“amount”}时,它返回无法读取未定义的属性“amount”

您可能需要使用带有点符号的运算符,如下所示:

{{wallet?.amount}}
当值未定义时,这不会引发错误,因为在API请求完成之前它是未定义的。顺便说一句,这与Ionic无关,它更像是一个角度问题