Skip to content
Permalink
Browse files
keyup.enterイベント削除/removeTodoメソッド追加/buttonのclickイベントに紐付け
  • Loading branch information
sin-tanaka committed Sep 25, 2017
1 parent 9223827 commit 03619d921d285683527cf64da408541ffb97756a
Showing 1 changed file with 8 additions and 4 deletions.
@@ -1,16 +1,15 @@
<template>
<div>
{{ msg }}
<form>
<button @click="addTodo()">ADD TASK</button>
<button>DELETE FINISHED TASKS</button>
<p>input: <input type="text" v-model="newTodo" @keyup.enter="addTodo()"></p>
<button @click="removeTodo()">DELETE FINISHED TASKS</button>
<p>input: <input type="text" v-model="newTodo"></p>
<p>task: {{ newTodo }}</p>
</form>
<div class="task-list">
<label class="task-list__item"
v-for="todo in todos">
<input type="checkbox"><button>EDIT</button>{{ todo.text }}
<input type="checkbox" v-model="todo.done"><button>EDIT</button>{{ todo.text }}
</label>
</div>
</div>
@@ -43,6 +42,11 @@ export default {
})
this.newTodo = ''
},
removeTodo: function (event) {
for (let i = this.todos.length - 1; i >= 0; i--) {
if (this.todos[i].done) this.todos.splice(i, 1)
}
}
}
}
</script>

0 comments on commit 03619d9

Please sign in to comment.