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

Related questions

0 votes
asked Sep 14, 2023 in VueJS by AdilsonLima
0 votes
asked Sep 15, 2023 in VueJS by JackTerrance
...