FrontendDeveloper.in

Vue.js question detail

What is object style commit?

You can also commit a mutation is by directly using an object that has a type property.

store.commit({
type: 'increment',
value: 20
})

Now the entire object will be passed as the payload to mutation handlers(i.e, without any changes to handler signature).

mutations: {
increment (state, payload) {
state.count += payload.value
}
}
Back to all Vue.js questions
Get LinkedIn Premium at Rs 399