怎样将两个数组对象合并为一个数组?
vue代码如下
//获取分类属性列表
async getCategoryAttributeList() {
const categoryMap = {
categoryCode: this.categoryCode,
};
const { data } = await getCategoryDetails(categoryMap);
const results = data;
this.attvaluearr = results;
const map = new Map();
const qc = results.filter(
(key) => !map.has(key.AttName) && map.set(key.AttName, 1)
); // 这里对name属性进行去重
let new_arr = qc.map((obj) => {
return obj.AttName;
});
let new_arr1 = qc.map((obj) => {
return obj.AttCode;
});
var array = [];
for (var item of new_arr) {
console.log(item);
var obj = new Object();
obj.AttName = item;
array.push(obj);
}
for (var item of new_arr1) {
var obj1 = new Object();
obj1.AttCode = item;
array.push(obj1);
}
this.attnamearr = array;
console.log(this.attnamearr);
},
目前attnamearr控制台打印为这样格式数据
Proxy {0: {…}, 1: {…}, 2: {…}, 3: {…}, 4: {…}, 5: {…}, 6: {…}, 7: {…}, 8: {…}, 9: {…}, 10: {…}, 11: {…}, 12: {…}, 13: {…}, 14: {…}, 15: {…}, 16: {…}, 17: {…}, 18: {…}, 19: {…}, 20: {…}, 21: {…}}
[[Handler]]: Object
[[Target]]: Array(22)
0: {AttName: 'IP等级'}
1: {AttName: '产地'}
2: {AttName: '停产'}
3: {AttName: '分线器类型'}
4: {AttName: '分线盒类型'}
5: {AttName: '协议类型'}
6: {AttName: '安装孔'}
7: {AttName: '安装方式'}
8: {AttName: '导体横截面'}
9: {AttName: '屏蔽'}
10: {AttName: '指示灯数量'}
11: {AttCode: '1000'}
12: {AttCode: '1001'}
13: {AttCode: '1002'}
14: {AttCode: '1003'}
15: {AttCode: '1004'}
16: {AttCode: '1005'}
17: {AttCode: '1006'}
18: {AttCode: '1007'}
19: {AttCode: '1008'}
20: {AttCode: '1009'}
21: {AttCode: '1010'}
希望将attnamearr变成如下格式数据
Proxy {0: {…}, 1: {…}, 2: {…}, 3: {…}, 4: {…}, 5: {…}, 6: {…}, 7: {…}, 8: {…}, 9: {…}, 10: {…}}
[[Handler]]: Object
[[Target]]: Array(11)
0: {AttName: 'IP等级' , AttCode: '1000'}
1: {AttName: '产地' , AttCode: '1001'}
2: {AttName: '停产' , AttCode: '10002'}
3: {AttName: '分线器类型' , AttCode: '1003'}
4: {AttName: '分线盒类型' , AttCode: '1004'}
5: {AttName: '协议类型' , AttCode: '1005'}
6: {AttName: '安装孔' , AttCode: '1006'}
7: {AttName: '安装方式' , AttCode: '1007'}
8: {AttName: '导体横截面' , AttCode: '1008'}
9: {AttName: '屏蔽' , AttCode: '1009'}
10: {AttName: '指示灯数量' , AttCode: '1010'}