Last active
August 19, 2020 10:10
-
-
Save LORD-KAY/9b91dbc19af24303264cc7e2a1398984 to your computer and use it in GitHub Desktop.
Vue JS Component implementing a simple dispatch action for vuex store
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> | |
<input type="text" v-model="todo" name="todo" id="addtodo"/> | |
<button @click="addTodo">Add New Todo</button> | |
</div> | |
</template> | |
<script> | |
export default { | |
name: "Todo", | |
data() { | |
return { | |
todo: "Buy milk at the grocery store" // default value for the input field | |
} | |
}, | |
methods: { | |
addTodo() { | |
this.$store.dispatch("addTodoItem", this.todo) | |
} | |
} | |
} | |
</script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment