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 

 

相关文章:

  • 2022-12-23
  • 2021-12-26
  • 2021-12-16
  • 2022-12-23
  • 2022-12-23
  • 2021-09-30
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2021-10-11
  • 2021-07-09
  • 2021-06-24
  • 2021-04-22
相关资源
相似解决方案