import Vuex from 'vuex'
const store = new Vuex.Store({ ...options })
state
Object
The root state object for the Vuex store.
mutations
Object | Array<Object>
An object where each entry's key is the mutation name and the value is a mutation handler function. The handler function always receives state
as the first argument, and receives all arguments passed to the dispatch call following that.
If passing in an Array of Objects, these objects will be automatically merged together into one final object.
actions
Object | Array<Object>
An object where each entry's key is the action name and the value is either
Vuex will process these entries and create the actual callable action functions and expose them on the actions
property of the store.
If passing in an Array of Objects, these objects will be automatically merged together into one final object.
getters
Object | Array<Object>
An object where each entry's key is the getter name and the value of a function which will receive the state as the first argument.
Vuex will process these entries and create the actual callable getter functions and expose them on the getters
property of the store.
If passing in an Array of Objects, these objects will be automatically merged together into one final object.
middlewares
Array<Object>
An array of middleware objects that are in the shape of:
{
snapshot: Boolean, // default: false
onInit: Function,
onMutation: Function
}
All fields are optional. Details
strict
Boolean
false
Force the Vuex store into strict mode. In strict mode any mutations to Vuex state outside of mutation handlers will throw an Error.
state
Object
The root state. Read only.
actions
Object
The callable action functions.
Directly dispatch a mutation. This is useful in certain situations are in general you should prefer using actions in application code.
Hot swap new actions and mutations. Details