AngularJS

关注公众号 jb51net

关闭
首页 > 网络编程 > JavaScript > javascript类库 > AngularJS > ng-repeat报错

AngularJS 使用ng-repeat报错 [ngRepeat:dupes]

投稿:lqh

这篇文章主要介绍了AngularJS 使用ng-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后面加上

track by $index 

感谢阅读,希望能帮助到大家,谢谢大家对本站的支持!

您可能感兴趣的文章:
阅读全文