您的位置:首页 > 其它

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

2015-11-03 15:25 411 查看


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

angularjs 使用ng-repeat报错

[html] view
plaincopy

<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

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

[html] view
plaincopy

<div ng-init="words = ['高校','高校','高校']" ng-repeat="word in words track by $index">

{{word}}

</div>

在ng-repeat后面加上

[html] view
plaincopy

track by $index
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: