Answer the question
In order to leave comments, you need to log in
How to work with vuex correctly?
Today I realized that I'm a fool who has been working with a view for some time and did not know that an object received through a getter can be changed directly. It turns out that I often made a commit, although the data had already been changed.
As I understand it, this is not desirable. I read that you need to turn on street mode.
Now this code throws an error. As you can see, before I didn't know that puzzles and so changes after a variety. Now the question is different. How to do it right. What if objects and arrays are passed by reference? do another copy operation?
shuffle({commit,getters}){
let puzzles = getters.getPuzzles
puzzles.sort((a,b) => Math.random() - 0.5)
commit('createPuzzles',puzzles)
commit('resetCounter')
commit('changeResult', false)
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question