0 votes
in VueJS by
What is object style commit?

1 Answer

0 votes
by

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
  }
}
...