vue v-for不重复渲染

<p v-for="item in arr" >{{item}} - {{$index}}</p>    //vue1

如果 item 有重复的 元素  由于vue 渲染机理   不会重复渲染   导致问题

解决方案:

<p v-for="item in arr"  track-by="$index" >{{item}} - {{$index}}</p>   //vue1
<p   v-for="(item , index) in arr"  v-bind:key="index" >{{item}} - {{$index}}</p>   //vue2
 

 

 



添加唯一值

原文地址:https://www.cnblogs.com/caoleyun/p/12692127.html