报错:Duplicate keys detected: ‘0‘. This may cause an update error. (key值不唯一问题)

报错信息如下:

报错:Duplicate keys detected: ‘0‘. This may cause an update error. (key值不唯一问题)

原代码:

<span v-for="(item,index) in blankTitle" :key="index">
    <span>{{item}}</span>
</span>
<span v-for="(resultItem,resultIndex) in resultData" :key="resultIndex">
    <span>{{resultItem}}</span>
</span>

如此会造成key值不唯一。

修改后代码:

<span v-for="(item,index) in blankTitle" :key="index">
    <span>{{item}}</span>
</span>
<span v-for="(resultItem,resultIndex) in resultData" :key="resultIndex+100">
    <span>{{resultItem}}</span>
</span>

根据情况将两个key值加以区分即可。

上一篇:Cisdem Duplicate Finder:快速查找和删除苹果Mac中重复文件


下一篇:2021-03-01