C
C
chincharovpc2019-11-25 13:33:05
Vue.js
chincharovpc, 2019-11-25 13:33:05

How to remove one element from an array in Vuex?

There is an array

state.test.questions
in Vux.
I need to remove any 1 element from this array.
I write...
removeQuestion(state,index) {
        let questions = state.test.questions
        questions.splice(index, 1)
        state.test = {
            ...state.test,
            questions:questions,
        };
    }

As I understand it
let questions = state.test.questions
assigns questions a link to the repository. And in storage there is an element which I want to delete.
How to do it differently?

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question