deepClone.ts-方法封装
import Vue from 'vue';
import Component from 'vue-class-component';
@Component
export default class DeepClone extends Vue {
public deepClone(target: any) {
const newTarget = Array.isArray(target) ? [] : {};
for (const key in target) {
if (typeof target[key] === 'object' && target[key]) {
newTarget[key] = this.deepClone(target[key]);
} else {
newTarget[key] = target[key];
}
}
return newTarget;
}
}