repeat报错 [ngRepeat:dupes]

AngularJS 使用ng-repeat报错

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

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后面加上

内容版权声明:除非注明,否则皆为本站原创文章。

转载注明出处:https://www.heiqu.com/wwdggw.html