[ngRepeat:dupes] Duplicates in a repeater are not allowed. Use 'track by' expression to spec

Posted karila

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了[ngRepeat:dupes] Duplicates in a repeater are not allowed. Use 'track by' expression to spec相关的知识,希望对你有一定的参考价值。

AngularJS 使用ng-repeat报错

 

<div ng-init="words = [‘高校‘,‘高校‘,‘高校‘]" ng-repeat="word in words">  
    {{word}}  
</div> 

  

[ngRepeat:dupes] Duplicates in a repeater are not allowed. Use ‘track by‘ expression to specify unique keys

  发现是因为相同的内容重复引起,解决方案

<div ng-init="words = [‘高校‘,‘高校‘,‘高校‘]" ng-repeat="word in words track by $index">  
    {{word}}  
</div>  

在ng-repeat后面加上  

track by $index  

  

以上是关于[ngRepeat:dupes] Duplicates in a repeater are not allowed. Use 'track by' expression to spec的主要内容,如果未能解决你的问题,请参考以下文章

Error: [ngRepeat:dupes] Duplicates in a repeater are not allowed.报错

angularjs基础ng-repeat嵌套循环报错angular.min.js:89 Error: [ngRepeat:dupes]

[ngRepeat:dupes] Duplicates in a repeater are not allowed. Use 'track by' expression to spec

angularJS问题集结

ng-repeat 之 track by $index

ng-repeat 的重复问题