美文网首页
ng-repeat重复问题解决

ng-repeat重复问题解决

作者: HughesCZB | 来源:发表于2017-10-11 18:06 被阅读0次

    当你在ng-repeat之后再使用一次会出现这样的报错
    [ngRepeat:dupes] Duplicates in a repeater are not allowed.

      <div  ng-repeat="item in allComment">
          <div  ng-repeat = "src in item.photoSrc ">
               ![]({{src}})
          </div>
      </div>
    
    

    解决办法 加上track by $index

      <div  ng-repeat="item in allComment">
          <div  ng-repeat = "src in item.photoSrc track by $index ">
                ![]({{src}})
          </div>
      </div>
    
    

    相关文章

      网友评论

          本文标题:ng-repeat重复问题解决

          本文链接:https://www.haomeiwen.com/subject/lpawyxtx.html