How can I clone data from Vuex state to local data?

后端 未结 3 1914
别那么骄傲
别那么骄傲 2021-01-05 16:42

How can I clone data from vuex state to local data attribute?

State

this.tsStore.shemes

Data Attribute



        
3条回答
  •  旧时难觅i
    2021-01-05 17:13

    You need to create a new array. this.tsStore.shemes give you a reference to the bound array. You can try to use the spread operator or arr.slice() to create a new array with the same content. notice that this is a shallow copy.

    this.shemes = [...this.tsStore.shemes]
    

    or

    this.shemes = this.tsStore.shemes.slice()
    

提交回复
热议问题