1.两个数组对象合入一起
const cc = [
{
id: 1,
age: '80岁',
name: '444',
},
{
id: 1,
age: '804岁',
name: '2',
},
{
id: 1,
age: '803岁',
name: '3',
},
{
id: 1,
age: '830岁',
name: '33',
},
{
id: 1,
age: '1022220岁',
name: '白龙马111111111',
},
]
const reslutList = [
{
id: 1,
age: 'age',
name: '唐曾',
},
{
id: 1,
age: '500岁',
name: '孙悟空',
},
{
id: 1,
age: '800岁',
name: '猪八戒',
},
{
id: 1,
age: '200岁',
name: '沙和尚',
},
{
id: 1,
age: '100岁',
name: '白龙马',
},
]
let op = cc.map((item, index) => {
return { ...item, ...reslutList[index] }
})
console.log(op, 'ooooooooooooooooooooooooo')
将两个数组合并为一个数组对象
let qw = ['唐曾', '孙悟空', '猪八戒', '沙和尚', '白龙马']
let err = ['30岁', '500岁', '800岁', '200岁', '100岁']
let arrObj = []
arrObj = qw.map((item, index) => {
return { label: item, value: err[index] }
})
console.log(arrObj, 'arrObjarrObj')