vue中v-for索引不要用key

今天发现在给元素v-for渲染的时候,想给元素添加key特性存储索引,发现不奏效:

<div class="apic" v-for="(pic,index) in msg.pics"   ...>
<img :src="pic" :key="index">

key特性在渲染后是不出现的。

将key改为其他自定义名称即可,比如:

<img :src="pic" :pic-key="index">
原文地址:https://www.cnblogs.com/alan2kat/p/7434929.html