Skip to content

Added keys to examples on List Rendering #810

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jan 15, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/guide/introduction.md
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ There are quite a few other directives, each with its own special functionality.
```html
<div id="list-rendering">
<ol>
<li v-for="todo in todos" v-bind:key="todo.text">
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@skirtles-code after some thinking I agreed with your point and removed this attribute to prevent a cognitive overhad

<li v-for="todo in todos">
{{ todo.text }}
</li>
</ol>
Expand Down
10 changes: 5 additions & 5 deletions src/guide/list.md
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ Sometimes we want to display a filtered or sorted version of an array without ac
For example:

```html
<li v-for="n in evenNumbers">{{ n }}</li>
<li v-for="n in evenNumbers" :key="n">{{ n }}</li>
```

```js
Expand All @@ -188,7 +188,7 @@ In situations where computed properties are not feasible (e.g. inside nested `v-

```html
<ul v-for="numbers in sets">
<li v-for="n in even(numbers)">{{ n }}</li>
<li v-for="n in even(numbers)" :key="n">{{ n }}</li>
</ul>
```

Expand All @@ -211,7 +211,7 @@ methods: {

```html
<div id="range" class="demo">
<span v-for="n in 10">{{ n }} </span>
<span v-for="n in 10" :key="n">{{ n }} </span>
</div>
```

Expand All @@ -225,7 +225,7 @@ Similar to template `v-if`, you can also use a `<template>` tag with `v-for` to

```html
<ul>
<template v-for="item in items">
<template v-for="item in items" :key="item.msg">
<li>{{ item.msg }}</li>
<li class="divider" role="presentation"></li>
</template>
Expand All @@ -251,7 +251,7 @@ When they exist on the same node, `v-if` has a higher priority than `v-for`. Tha
This can be fixed by moving `v-for` to a wrapping `<template>` tag:

```html
<template v-for="todo in todos">
<template v-for="todo in todos" :key="todo.name">
<li v-if="!todo.isComplete">
{{ todo }}
</li>
Expand Down