Nuxt/examples/vuex-store-modules/store/todos.js

23 lines
290 B
JavaScript
Raw Normal View History

export const state = () => ({
2016-12-25 20:16:30 +00:00
list: []
})
2016-12-25 20:16:30 +00:00
export const mutations = {
2017-10-31 13:43:55 +00:00
add(state, { text }) {
2016-12-25 20:16:30 +00:00
state.list.push({
text,
done: false
})
},
2017-10-31 13:43:55 +00:00
toggle(state, todo) {
2016-12-25 20:16:30 +00:00
todo.done = !todo.done
}
}
2017-02-12 10:48:07 +00:00
export const getters = {
2017-10-31 13:43:55 +00:00
todos(state) {
2017-02-12 10:48:07 +00:00
return state.list
}
}