Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

image

我标出来箭头的是对应的商品门店 每个商品门店下面有对应的商品
我要怎么把新的数组格式改为[{
"89": "111,222,333"
},{"90": "111,222,333"}]
这种格式的,就是左边key值是门店id,
右边value值是对应门店的商品id拼接


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
471 views
Welcome To Ask or Share your Answers For Others

1 Answer

直接循环处理,

let arr1 = [];
for(let k in arr){
    arr1.push({
        [arr[k].storeId]:arr[k].lists.join(',')
    })
}

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...