Skip to content

Instantly share code, notes, and snippets.

@LORD-KAY
Last active November 9, 2021 07:33
Show Gist options
  • Save LORD-KAY/211e42aa0436a96e98ee3de1c699fb7b to your computer and use it in GitHub Desktop.
Save LORD-KAY/211e42aa0436a96e98ee3de1c699fb7b to your computer and use it in GitHub Desktop.
A sample index.js depicting the vuex code structure and definitions
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