对于大量输入绑定(例如在列表中重复使用组件),应该使用单向绑定而不是双向绑定。这可以通过改变changeDetection策略来实现,将组件更改检测的频率从默认的OnPush更改为Default。
示例代码:
@Component({ selector: 'app-item', templateUrl: './item.component.html', changeDetection: ChangeDetectionStrategy.Default // 修改changeDetection策略 }) export class ItemComponent { @Input() item: Item; constructor() { } }