可能的原因是因为绑定的属性值在更新时没有通知Angular应用程序。要解决这个问题,可以做以下两件事情:
this.myClass = 'new-class'; this.cd.detectChanges();
setTimeout(() => { this.myClass = 'new-class'; }, 0);
这些方法都能确保更新CSS类样式后,Angular应用程序会刷新并显示正确的样式。
上一篇:绑定ContextMenu到ItemsSource有问题。
下一篇:绑定存储上的动态属性