我正在使用 ngOnChanges,并且已将 SimpleChange 参数设置如下。为什么我可以使用 changes.currentValue 直接访问我的输入属性,而不必使用索引获取属性?两者都工作,我很困惑为什么?
ngOnChanges(changes: SimpleChange) {
console.log('ngOnChanges called with changes value: ', changes.currentValue) // why does this work? is it because by convention it works if I have just one input property??
for (const propName in changes) {
console.log('ngOnChanges called with propName value: ', changes[propName].currentValue)
}
}