首先
typeof a === ‘array’
当数据项相同,且:key='v’会报错
代码示例:
<template lang="pug">
div
ul
li(
v-for='(v, k) in a'
:key='v'
) {{v}} -- {{k}}
</template>
<script>
export default {
data(){
return {
a: [2,2,4],
}
},
}
</script>
[Vue warn]: Duplicate keys detected: '2'. This may cause an update error.
found in
---> <App> at app.vue
<Root>
请问怎么解释?