AngularJS 使用ng-repeat報錯
[ngRepeat:dupes] Duplicates in a repeater are not allowed. Use 'track by' expression to specify uniq
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
感謝閱讀,希望能幫助到大家,謝謝大家對本站的支持!
新聞熱點
疑難解答