Skip to content

Instantly share code, notes, and snippets.

@nejtr0n
Forked from stephanepericat/nested-vuex-modules.js
Created August 9, 2018 17:36
Show Gist options
  • Select an option

  • Save nejtr0n/a55d37d39af36af6e27d78ee186bf803 to your computer and use it in GitHub Desktop.

Select an option

Save nejtr0n/a55d37d39af36af6e27d78ee186bf803 to your computer and use it in GitHub Desktop.
Vuex Nested Modules
export default {
namespaced: true,
state: {
firstname: 'John',
lastname: 'Doe',
email: '[email protected]'
},
getters: {
fullname: state => `${state.firstname} ${state.lastname}`
},
mutations: {
updatemail(state, email) {
state.email = email;
}
},
actions: {
emailupdate(context, email) {
context.commit('updatemail', email);
}
},
modules: {
account: {
state: {
type: 'Admin',
created: '2018-01-12 21:33:54 UTC',
active: true
}
},
posts: {
namespaced: true,
state: {
articles: [...]
}
}
}
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment