如何解决如何访问接口的对象属性,该属性是另一个接口的属性的类型?我想要的属性在数组
例如:
第一个界面
export interface IUser {
_id: string;
name: string;
profile: IUserProfile;
}
第二界面
export interface IUserProfile {
_id: string;
first_name: string;
last_name: string;
social_media: IUserProfileSocialMedia[];
}
第三界面
export interface IUserProfileSocialMedia {
_id?: string;
status?: EUserProfileSocailMediaStatus;
platform: string;
}
Enum 用于良好度量
export enum EUserProfileSocailMediaStatus {
NEW = 'New',CHANGED = 'Changed',REMOVED = 'Removed',}
当我
console.log this.user.profile.social_media
我得到了对象数组。但是一旦我这样做
this.user.profile.social_media.status
或
this.user.profile.social_media.platform
我仍然只得到对象数组。这是对象数组的样子:
{
platform: "Facebook"
status: "Changed"
_id: "1"
}
但我只需要抓住平台或状态。这有意义吗?谢谢!
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。