F
F
FOGstudio2017-08-06 01:02:12
Vue.js
FOGstudio, 2017-08-06 01:02:12

What is the correct way to delete an object in VUEX?

There is an object state.items[id] of the list of items. You need to correctly remove the item from the list.
I did it with the help of a mutation with the delete state.items[id] code, the object was deleted, but reactivity did not work.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
R
Ramil, 2017-08-06
@FOGstudio

In vue 2, removing via the $remove method is considered deprecated. Use Vue.delete.

I
Igor Koch, 2017-08-06
@amux

mutations:{
    REMOVE_ITEM (state, id) {
      state.items.$remove(id)
    }
}

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question