Skip to content

Commit ea87e49

Browse files
committed
Specify which types are allowed as values for 'key' of 'v-for'
1 parent 42348d2 commit ea87e49

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

src/v2/guide/list.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -221,7 +221,7 @@ When Vue is updating a list of elements rendered with `v-for`, by default it use
221221

222222
This default mode is efficient, but only suitable **when your list render output does not rely on child component state or temporary DOM state (e.g. form input values)**.
223223

224-
To give Vue a hint so that it can track each node's identity, and thus reuse and reorder existing elements, you need to provide a unique `key` attribute for each item. An ideal value for `key` would be the unique id of each item. This special attribute is a rough equivalent to `track-by` in 1.x, but it works like an attribute, so you need to use `v-bind` to bind it to dynamic values (using shorthand here):
224+
To give Vue a hint so that it can track each node's identity, and thus reuse and reorder existing elements, you need to provide a unique `key` attribute for each item. An ideal value for `key` would be the unique id of each item, also avoid using non-primitive values as key, use string/number value instead. This special attribute is a rough equivalent to `track-by` in 1.x, but it works like an attribute, so you need to use `v-bind` to bind it to dynamic values (using shorthand here):
225225

226226
``` html
227227
<div v-for="item in items" :key="item.id">

0 commit comments

Comments
 (0)