[Vuejs]-Vuex – Shared server side state?

-1👍

I’m confused as to what you mean by “server-side state”. Vuex is a client side store. What and why are you saving state to the server?

Furthermore, I cannot tell what you are doing with the code? Is that in a store.js file? In the mutations object?

You would need to wrap that in a vue method like so:

In the Vue file:

methods: {
  clicksButton (idx) {
    this.$store.commit('read_notification', idx)
  }
}

In the store.js file:

const store = new Vuex.Store({
  state: {
    data: [],
    error: null
  },
  mutations: {
    read_notification (state, idx) {
      state.data.splice(idx, 1)
    }
  }
}

Leave a comment