1
votes

This question maybe the most noob outwhere, but I cannot find out.

First, assign variable from store state

this.currentLoadNode = this.$store.state.loadNode

Modify variable

this.currentLoadNode.shift();

EDIT to avoid misreading: I don't look for modify Vuex state (I know commit mutation) , I just want to modify my currentLoadNode variable. However, in a mystery way, Vuex also modify loadNode state and throw me this error

[Vue warn]: Error in callback for watcher "function () { return this._data.$$state }": "Error: [vuex] do not mutate vuex store state outside mutation handlers."

Hope anyone enter this issue and could give me a help. Tks

1

1 Answers

2
votes

I think they point to the same address in memory. You can try creating a copy

this.currentLoadNode = JSON.parse(JSON.stringify(this.$store.state.loadNode))

or ES6 syntax

this.currentLoadNode = [...this.$store.state.loadNode]