Skip to content
Permalink
Browse files
methodsにaddTodoメソッドを追加/buttonのclickイベントにaddTodoを紐付け
  • Loading branch information
sin-tanaka committed Sep 25, 2017
1 parent cc50c58 commit 06b522cdbbeeaad51bf99fe638ceebca64ba7503
Showing 1 changed file with 18 additions and 17 deletions.
@@ -2,7 +2,7 @@
<div>
{{ msg }}
<form>
<button>ADD TASK</button>
<button v-on:click="addTodo()">ADD TASK</button>
<button>DELETE FINISHED TASKS</button>
<p>input: <input type="text" v-model="newTodo"></p>
<p>task: {{ newTodo }}</p>
@@ -23,25 +23,26 @@ export default {
return {
msg: 'Welcome to Your Vue.js App',
todos : [
{
text : 'vue-router',
done: false
},
{
text : 'vuex',
done: false
},
{
text : 'vue-loader',
done: false
},
{
text : 'awesome-vue',
done: true
},
{text : 'vue-router', done: false},
{text : 'vuex', done: false},
{text : 'vue-loader', done: false},
{text : 'awesome-vue', done: true},
],
newTodo: ""
}
},
methods: {
addTodo: function(event) {
let text = this.newTodo && this.newTodo.trim()
if (!text) {
return
}
this.todos.push({
text: text,
done: false
})
this.newTodo = ''
},
}
}
</script>

0 comments on commit 06b522c

Please sign in to comment.