[Vuejs]-Vuex Error, when sorting local Array

2👍

Array.prototype.sort mutates the array that you call it on.

Assuming that cmp.getPurposesAllowed() returns a reference to an array in your vuex store, your are mutating that array from the store, just like the error message says.

Solution: Make a shallow copy of the array before:

let purposeArrayZ = cmp.getPurposesAllowed().slice();

Leave a comment