且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

添加新项目后 ngRepeat 会重新渲染所有项目吗?

更新时间:2023-12-03 12:49:58

从 Angular 1.2 开始,我们就有了 'track by' 选项,可以防止转发器重新渲染所有项目.

Since Angular 1.2 we have the 'track by' option which will prevent the repeater from re-rendering all the items.

示例:

ng-repeat="task in tasks track by task.id"

看看这个解释:http://www.codelord.net/2014/04/15/improving-ng-repeat-performance-with-track-by/