Skip to content

Instantly share code, notes, and snippets.

@Dirk94
Created February 1, 2021 12:46
Show Gist options
  • Select an option

  • Save Dirk94/a2d01f79ecc6c587a8c11816e99ea7ac to your computer and use it in GitHub Desktop.

Select an option

Save Dirk94/a2d01f79ecc6c587a8c11816e99ea7ac to your computer and use it in GitHub Desktop.
<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