npm install
npm run serve
npm run build
npm run lint
npm i -g json-server
json-server --watch db.json
In a component method, a mutation can be commited but it's better to dispatch an action that will commit a mutation.
/store/index.js
import * as name from '@/store/modules/name.js'
/store/modules/name.js
export const state = { ... }
export const mutations = { ... }
export const actions = { ... }
export const getters = { ... }
/store/index.js
import name from '@/store/modules/name.js'
/store/modules/name.js
export default {
state: { ... },
mutations: { ... },
actions: { ... },
getters: { ... }
}
Mutations should not be called from other Vuex Modules. Mutations should only be called from Actions inside the current Module.