N
N
nurdus2018-12-30 09:14:35
Vue.js
nurdus, 2018-12-30 09:14:35

Is it possible to write mutation in vuex via Object.assign?

Good morning
In vuex there is a User module which will be like this:

state: {
  _id: "",
  firstName: "",
  lastName: "",
  middleName: ""
}

is it possible to use state = Object.assign(state, payload) in mutations or maybe there is another more correct way (or best practices):
mutations: {
  SET_USER(state, payload = {}) {
    state = Object.assign(state, payload)
  }
},

Answer the question

In order to leave comments, you need to log in

1 answer(s)
0
0xD34F, 2018-12-30
@nurdus

I allow. Write.
Just figure out what this thing is, Object.assign, what it does. And then you obviously don’t fully understand something, judging by the shown bit of code.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question