let arr = result.data;
const copyObj = (objs = {}) => { //变量先置空
let newobj = null;
//判断是否需要继续进行递归
if (typeof(objs) == 'object' && obj !== null) {
newobj = objs instanceof Array ? [] : {}; //进行下一层递归克隆
for (var i in objs) {
newobj[i] = copyObj(objs[i])
} //如果不是对象直接赋值
} else newobj = objs;
return newobj;
}
this.screenList = copyObj(arr)
js比较实在的深拷贝
于 2023-04-04 15:18:03 首次发布