【发布时间】:2019-05-08 02:24:09
【问题描述】:
我想将值system 更新为对象telecom,但在此阶段它会显示此错误
无法分配给对象“[对象”的只读属性“系统” 对象]'
this.organization.telecoms.forEach((telecom: Telecom) =>
telecom.system = 'test'
);
console.log(this.organization);
export class Organization {
public effectiveDate?: EffectiveDate;
public identifiers?: IdentifierOrg[];
public kilometerZones?: KilometerZone[];
public telecoms?: Telecom[];
}
export class Telecom {
public system?: string;
public value?: string;
}
【问题讨论】:
-
Object.defineProperty(telecom, 'system', { value: 'test' }); -
(或者你删除
readonly属性) -
@trichetriche 谁可以删除只读属性?
-
尝试从
foreach中删除: Telecom -
也可以试试
forEach((telecom: any)
标签: angular typescript