我有一个带有输入和变量的组件:
@Input() data: string[];
@Input() val: string = '';
ngOnChanges(changes: SimpleChanges) {
for (let propName in changes) {
if (propName == 'data') {
this.val = 'hello';
}
}
}
问题是,我需要在数据更改时更改输入值。但我有以下错误:
Expression has changed after it was checked. Previous value: 'false'. Current value: 'true'.
谢谢 !