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

View File

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