Permalink
Browse files

create todo with @keyup.enter

  • Loading branch information...
amejiarosario committed Aug 13, 2018
1 parent 3dc4871 commit fcd305c776e295219345d8e5b7e9e29ff8f9623e
Showing with 10 additions and 1 deletion.
  1. +7 −0 app.js
  2. +3 −1 index.html
7 app.js
@@ -7,5 +7,12 @@ const todoApp = new Vue({
{ text: 'Learn Vue', isDone: false },
{ text: 'Build something awesome', isDone: false },
],
},
methods: {
createTodo(event) {
const textbox = event.target;
this.todos.push({ text: textbox.value, isDone: false });
textbox.value = '';
}
}
});
@@ -14,7 +14,9 @@
<section class="todoapp">
<header class="header">
<h1 v-text="title"></h1>
<input class="new-todo" placeholder="What needs to be done?" autofocus>
<input class="new-todo" placeholder="What needs to be done?"
v-on:keyup.enter="createTodo"
autofocus>
</header>
<!-- This section should be hidden by default and shown when there are todos -->

0 comments on commit fcd305c

Please sign in to comment.