Last active
November 9, 2021 07:33
-
-
Save LORD-KAY/211e42aa0436a96e98ee3de1c699fb7b to your computer and use it in GitHub Desktop.
A sample index.js depicting the vuex code structure and definitions
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
const state = { | |
todos: [] | |
} | |
const mutations = { | |
ADD_TODO(state, payload) { | |
state.todos.push(payload) | |
} | |
} | |
const actions = { | |
addTodoItem({commit}, payload) { | |
commit("ADD_TODO", payload) | |
} | |
} | |
const getters = { | |
getAllTodos: state => state.todos | |
} | |
export default { | |
state, | |
mutations, | |
actions, | |
getters | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment