Skip to content

Commit e9c3020

Browse files
hkraalphanan
authored andcommitted
Use keyed loop (vuejs#1767)
Per https://vuejs.org/v2/style-guide/#Keyed-v-for-essential the loop should be keyed, I feel this should be reflected in the guide.
1 parent 8b1b15a commit e9c3020

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

src/v2/guide/index.md

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,9 @@ There are quite a few other directives, each with its own special functionality.
151151
``` html
152152
<div id="app-4">
153153
<ol>
154-
<li v-for="todo in todos">
154+
<li v-for="todo in todos"
155+
:key="todo.id"
156+
>
155157
{{ todo.text }}
156158
</li>
157159
</ol>
@@ -162,9 +164,9 @@ var app4 = new Vue({
162164
el: '#app-4',
163165
data: {
164166
todos: [
165-
{ text: 'Learn JavaScript' },
166-
{ text: 'Learn Vue' },
167-
{ text: 'Build something awesome' }
167+
{ id: 1, text: 'Learn JavaScript' },
168+
{ id: 2, text: 'Learn Vue' },
169+
{ id: 3, text: 'Build something awesome' }
168170
]
169171
}
170172
})

0 commit comments

Comments
 (0)