【AngularJS ng-repeat指令中使用track by子语句解决重复数据遍历错误问题】教程文章相关的互联网学习教程文章

AngularJS ng-repeat指令中使用track by子语句解决重复数据遍历错误问题

本文实例讲述了AngularJS ng-repeat指令中使用track by子语句解决重复数据遍历错误问题。分享给大家供大家参考,具体如下: 我们可以使用ng-repeat指令遍历一个JavaScript数组,当数组中有重复元素的时候,AngularJS会报错: Error: [ngRepeat:dupes] Duplicates in a repeater are not allowed. Use track by expression to specify unique keys. Repeater: user in users, Duplicate key: number:1。下面的代码就会报错: <html><h...