val的格式是[ {},{},{}]
第一种、拼接成一个新的数组套json对象的格式
if(val instanceof Array){
var arr = [];
val.forEach(item => {
let obj = {}
obj[item.id] = item.name + "*" + item.number
arr.push(obj)
});
this.newArray = [...arr]
}
第二种、拼接成一个json对象
if(val instanceof Array){
let obj = {}
val.forEach(item => {
obj[item.id] = item.name + "*" + item.number
});
this.newArray = obj
}
console.log(this.newArray)