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
添加唯一值
- 上一篇 »Vue v-for操作与computed结合功能
- 下一篇 »Vue v-for操作对象与数值