In your case you need to clone the multidimensional array.
There are 2 types of array cloning: shallow & deep. Shallow copies only cover the 1st level of the array and the rest are referenced. If you want a true copy of nested arrays, you’ll need a deep clone. For deep clones, go with the JSON way OR better yet use Lodash
// Using JavaScript
let data = JSON.parse(JSON.stringify(store.getters['getTestStoreData']));
Or
// Using Lodash
let data = _.cloneDeep(store.getters['getTestStoreData']);
To test out the Lodash clone and clonedeep functions, you will need to install Lodash first:
npm install --save lodash
Or
yarn add lodash
With lodash now installed, use the require() function to now access all the functions that Lodash has too offer:
// vuex
import { mapState } from 'vuex'
// store
import store from './../store';
// types
import { ServiceType } from './../types/services'
const _ = require('lodash'); // Line to be included
export default class TestService implements ServiceType {
.........
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…