Unlike Vue apps, in Nuxt, the namespaced key is set to true by default for each module, as well as the root module. Also, in Nuxt, you do not need to assemble modules in the store root; you just need to export the state as a function, and the mutations, getters, and actions as objects in the root and module files. Let's get things going with the following steps:
- Create a store root, as follows:
// store/index.js
export const state = () => ({
number: 3
})
export const mutations = {
mutation1 (state) { ... }
}
export const getters = {
getter1 (state, getter) { ... }
}
export const actions = {
action1 ({ state, commit }) { ... }
}
In Nuxt, Vuex's strict mode is set to true by default during development and turned off automatically in production mode, but you can disable that during development, as follows:
// store/index.js
export const strict = false
- Create a module, as follows:
// store/module1.js
export const state = () => ({
number...