[Vuejs]-Mutating data in computed property also changed data in vuex store: why? Any help is appreciated

3👍

You are assigning to myOrder the reference of this.order, subsequently all your modifications inside it will affect this.order (so you are mutating).

In this case, since you just want to modify products, you can shallow copy this.order just like this:

let myOrder = { ...this.order };

Then, all the properties at the first level will have different pointers, so you can change them without fear of mutations.

Leave a comment