There are multiple ways to solve your problem :
- You want to iterate on a
template
:
You have to put a key on all elements in your template because you can not put akey
on atemplate
:<template> cannot be keyed. Place the key on real elements instead.
<template v-for="(project, index) in existingProjects">
<span :key="project.projectId">foo</span>
<div :key="project.projectId">bar</div>
</template>
- You can iterate on something else than a
template
: You just put thekey
on the parent html tag.
<div v-for="(project, index) in existingProjects" :key="project.projectId">
<span>foo</span>
<div>bar</div>
</div>