当前位置: 移动技术网 > IT编程>脚本编程>AngularJs > AngularJS 使用ng-repeat报错 [ngRepeat:dupes]

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

2018年05月03日  | 移动技术网IT编程  | 我要评论

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 

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

如对本文有疑问, 点击进行留言回复!!

相关文章:

验证码:
移动技术网