vue报错——[vue/require-v-for-key]Elements in iteration expect to have ‘v-bind:key‘ directives.

[vue/require-v-for-key]
Elements in iteration expect to have 'v-bind:key' directives.

[vue/require-v-for-key]
迭代中的元素期望具有“v-bind:key”指令。

在v-for循环中,

<li v-for="n in imgData">
    <img :src=n.url />
</li>

会报错

解决方法:

v-for循环后加上:key=""。Vue 2.2.0+的版本里,当在组件中使用v-for时,key是必须的

<li v-for="n in imgData" :key="n">
    <img :src=n.url />
</li>

参考:https://blog.csdn.net/ITarmi/article/details/108917360