0

So I have a very similar Application Structure to the example below https://github.com/vuejs/vuex/tree/dev/examples/shopping-cart

However, there is no root mutations defined there. I need to create one since I have to update the state that is dynamically created in vue-tables-2.

In my mutation-types.js I declared the name of the mutation as

export const UPDATE_CLIENTTABLE = 'UPDATE_CLIENTTABLE'

However, I'm not sure how to write the mutations in mutations.js There's no module defined because the state is dynamically created by vue-tables-2. I'm doing something like below but it doesn't work

[types.UPDATE_CLIENTTABLE] (state, data) {
    state.ClientTableLine.data = data
}
Kay Singian
  • 1,301
  • 8
  • 20
  • 33

1 Answers1

0

You'll need to export your mutation in your mutations.js file

export const [types.UPDATE_CLIENTTABLE) = (state, data) => {
  state.ClientTableLine.data = data
}

Then import it into your vuex set up

import * as mutations from './mutations'
export default new Vuex.Store({
  mutations,
  actions,
  getters,
  modules: {
    cart,
    products
  },
  strict: debug,
  plugins: debug ? [createLogger()] : []
})

This is assuming your vuex set up is taken from the shopping car example

Matt Sugden
  • 844
  • 6
  • 12