Created
February 1, 2021 12:46
-
-
Save Dirk94/a2d01f79ecc6c587a8c11816e99ea7ac to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <template> | |
| <div id="app"> | |
| <h1>Todo App</h1> | |
| <input type="text" @keyup.enter="addTodo()" v-model="message" placeholder="Add a to-do"> | |
| <ul> | |
| <li v-for="todo in todos" :key="todo.message"> | |
| {{ todo.message }} | |
| </li> | |
| </ul> | |
| </div> | |
| </template> | |
| <script> | |
| export default { | |
| name: 'App', | |
| data() { return { | |
| message: "", | |
| } }, | |
| methods: { | |
| addTodo() { | |
| this.$store.commit("ADD_TODO", { | |
| completed: false, | |
| message: this.message, | |
| }); | |
| this.message = ""; | |
| } | |
| }, | |
| computed: { | |
| todos() { | |
| return this.$store.state.todos; | |
| }, | |
| }, | |
| } | |
| </script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment