嘿,我正在将对象从一个页面传递到另一个页面&试图将对象存储在另一个页面中,但在此过程中遇到了一个错误。
accountData:any={
name:this.tenantAccount.name,
telephone_number:this.tenantAccount.telephone_number,
mobile_number:this.tenantAccount.owner.mobile_number,
address:this.tenantAccount.address.address,
owner_name:this.tenantAccount.owner.name,
tenant_email:this.tenantAccount.tenant_email,
created_by:this.tenantAccount.created_by.name,
source_name:this.tenantAccount.source.name,
latitude:this.tenantAccount.address.latitude,
longitude:this.tenantAccount.address.longitude,
state:this.tenantAccount.address.state.name
}
上面那个是要存储的代码,是因为 typescript
为什么会发生这种情况?最佳解决方案是什么
1条答案
按热度按时间olmpazwi1#
根据错误
Property 'address' does not exist on type 'string'
,this.tenantAccount.address
是字符串类型,但根据您的代码,您将其视为对象,并尝试从其访问address
属性,根据错误,这是不正确的。我认为应该是
this.tenantAccount.address ✅
而不是this.tenantAccount.address.address ❌