diff --git a/src/v2/guide/list.md b/src/v2/guide/list.md index 0f223e64f5..9e81bcc4fb 100644 --- a/src/v2/guide/list.md +++ b/src/v2/guide/list.md @@ -249,8 +249,8 @@ Here's a complete example of a simple todo list:
  • @@ -273,14 +273,27 @@ new Vue({ data: { newTodoText: '', todos: [ - 'Do the dishes', - 'Take out the trash', - 'Mow the lawn' - ] + { + id: 1, + title: 'Do the dishes', + }, + { + id: 2, + title: 'Take out the trash', + }, + { + id: 3, + title: 'Mow the lawn' + } + ], + nextTodoId: 4 }, methods: { addNewTodo: function () { - this.todos.push(this.newTodoText) + this.todos.push({ + id: this.nextTodoId++, + title: this.newTodoText + }) this.newTodoText = '' } } @@ -288,7 +301,7 @@ new Vue({ ``` {% raw %} -
    +
    @@ -314,19 +327,33 @@ Vue.component('todo-item', { ', props: ['title'] }) + new Vue({ el: '#todo-list-example', data: { newTodoText: '', todos: [ - 'Do the dishes', - 'Take out the trash', - 'Mow the lawn' - ] + { + id: 1, + title: 'Do the dishes', + }, + { + id: 2, + title: 'Take out the trash', + }, + { + id: 3, + title: 'Mow the lawn' + } + ], + nextTodoId: 4 }, methods: { addNewTodo: function () { - this.todos.push(this.newTodoText) + this.todos.push({ + id: this.nextTodoId++, + title: this.newTodoText + }) this.newTodoText = '' } }