[英]Angular ngFor change detection with trackBy in Safari vs Chrome
I have an application connected with firebase, it fetches the whole object whenever any change happens to it. 我有一个与firebase连接的应用程序,只要发生任何更改,它都会获取整个对象。
Lets say I have an object like this: 可以说我有一个这样的对象:
{
count: 0,
media: [{
src: 'http://placehold.it/350x150'
}, {
src: 'http://placehold.it/350x250'
}]
};
whenever the count increases, I get the whole object from the backend with same src
values. 每当计数增加时,我都会从后端获得具有相同
src
值的整个对象。 Here's what happens when the data binds with the view: 当数据与视图绑定时,将发生以下情况:
src
. src
因此图像不会刷新。 (Expected behavior) I've also tried using trackBy: media?.src
but getting the same result. 我也尝试使用
trackBy: media?.src
但得到的结果相同。
Is this an issue with Angular's trackBy
or is it just how Safari works??? 这是Angular的
trackBy
还是Safari的工作原理???
The problem here is that trackBy: Object?.property
is deprecated and using a tracking function trackBy: trackByFn
works like a charm. 这里的问题是,不赞成使用
trackBy: Object?.property
,并且使用跟踪功能trackBy: trackByFn
就像一个trackBy: trackByFn
一样工作。
Though I think Chrome handles DOM changes more gracefully than Safari. 尽管我认为Chrome可以比Safari更优雅地处理DOM更改。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.