我有 Angular 写的项目 但是在我的组件中使用 ChangeDetectionStrategy.OnPush 我将 properti 更新为存储中的新值,但 UI 未更新 所以任何时候都可以帮我解决这个问题(可以使用 Obserbable for pipeAsync) 谢谢
使用 OnPush,你需要告诉 Angular Component 在事件之外检测变化和更新。 对于你的情况,我认为
this.cdRef.markForCheck(); // Tell Angular to run detectChanges on this component
可能有用。