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

 

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

angularjs 使用ng-repeat报错

[html]  view plain copy
  1.       
  2. <div ng-init="words = ['高校','高校','高校']" ng-repeat="word in words">  
  3.     {{word}}  
  4. </div>  

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

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

[html]  view plain copy
  1. <div ng-init="words = ['高校','高校','高校']" ng-repeat="word in words track by $index">  
  2.     {{word}}  
  3. </div>  

在ng-repeat后面加上

[html]  view plain copy
  1. track by $index  

angularjs 使用ng-repeat报错

[html]  view plain copy
  1.       
  2. <div ng-init="words = ['高校','高校','高校']" ng-repeat="word in words">  
  3.     {{word}}  
  4. </div>  

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

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

[html]  view plain copy
  1. <div ng-init="words = ['高校','高校','高校']" ng-repeat="word in words track by $index">  
  2.     {{word}}  
  3. </div>  

在ng-repeat后面加上

[html]  view plain copy
  1. track by $index  

猜你喜欢

转载自blog.csdn.net/u011704394/article/details/49616791