Usage of getters

This commit is contained in:
Sébastien Chopin 2017-02-12 11:48:07 +01:00
parent 32f1526c0b
commit e01093b2ac
2 changed files with 10 additions and 4 deletions

View File

@ -13,12 +13,12 @@
</template>
<script>
import { mapMutations } from 'vuex'
import { mapMutations, mapGetters } from 'vuex'
export default {
computed: {
todos () { return this.$store.state.todos.list }
},
computed: mapGetters({
todos: 'todos/todos'
}),
methods: {
addTodo (e) {
var text = e.target.value

View File

@ -14,3 +14,9 @@ export const mutations = {
todo.done = !todo.done
}
}
export const getters = {
todos (state) {
return state.list
}
}