[Vuejs]-We also need to provide each component with a "key" vuejs

0đź‘Ť

Vue uses the key attribute to "track" each node rendered by a v-for loop, for performance purpose.
You can find more information here https://v2.vuejs.org/v2/guide/list.html#key

0đź‘Ť

When Vue is updating a list of elements rendered with v-for, by default it uses an “in-place patch” strategy. If the order of the data items has changed, instead of moving the DOM elements to match the order of the items, Vue will patch each element in-place and make sure it reflects what should be rendered at that particular index. This is similar to the behavior of track-by="$index" in Vue 1.x.

that’s from the docs

Leave a comment