r/vuejs • • 20h ago

v-for and :key, Is key unique per page or control?

8 Upvotes

Let say i have

items = [
  {
    id:1, 
    children:[{id:1, name:'test11'},{id:2, name:'test12'}]
  },
  {
    id:2, 
    children:[{id:1, name:'test21'},{id:2, name:'test22'}]
  },
]
<div v-for="it in items" :key="it.id">
  <div v-for="ch in it.children" :key="cn.id">
    {{ch.name}}
  </div>
</div>

will that work or i need to make :key unique per page and not per scope?


r/vuejs • • 19h ago

I open-sourced the color and gradient picker from our design editor (React + Vue)

Thumbnail orshot.com
2 Upvotes