js 对象数组深拷贝
参考 https://chuna2.787528.xyz/xjnotxj/p/9810534.html
const _ = require('lodash');
let one_brand = [
{name: 'A', count: 1, value: Infinity},
{name: 'B', count: 2},
]
// 深拷贝
// 方法一
let two_brand = one_brand.map(o => Object.assign({}, o));
// 方法二
let two_brand = one_brand.map(o => ({...o}));
// 方法三(推荐)
let two_brand = _.cloneDeep(one_brand);
console.log("改变前:")
console.log(one_brand)
console.log(two_brand)
two_brand[1].count = 0;
console.log("改变后:")
console.log(one_brand)
console.log(two_brand)

浙公网安备 33010602011771号