码迷,mamicode.com
首页 > 其他好文 > 详细

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

时间:2017-07-19 14:08:58      阅读:125      评论:0      收藏:0      [点我收藏+]

标签:angular   uniq   ng-repeat   replace   知识   nbsp   title   href   pes   

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 specify uniq

标签:angular   uniq   ng-repeat   replace   知识   nbsp   title   href   pes   

原文地址:http://www.cnblogs.com/karila/p/7205029.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!