抱着猫睡觉的鱼_ 2021-09-24 15:20 采纳率: 52.6%
浏览 286
已结题

vue如何把多个对象的属性值合并到一个数组对象里面

数据格式如下,想把每一项中的skuName拿出来组成一个数组


let arr = [
    {
        "id": "46f7c6ba-b4ca-4843-b5d1-76399d1ac52a",
        "parentId": "a80ff169-d6f6-4752-b980-fd818240410f",
        "attributeName1": "颜色",
        "attributeValue1": "黄色",
        "attributeName2": "尺寸1",
        "attributeValue2": "S",
        "skuCode": "10",
        "skuName": "美年达1",
        "price": 10,
        "isShelf": "上架"
    },
    {
        "id": "2ea2a723-1a6c-4545-92ce-2ef07547642f",
        "parentId": "a80ff169-d6f6-4752-b980-fd818240410f",
        "attributeName1": "颜色",
        "attributeValue1": "黄色",
        "attributeName2": "尺寸1",
        "attributeValue2": "M",
        "skuCode": "11",
        "skuName": "可乐1",
        "price": 11,
        "isShelf": "上架"
    },
    {
        "id": "57bc93ad-84de-4737-8ca6-d6abe97eb9ae",
        "parentId": "a80ff169-d6f6-4752-b980-fd818240410f",
        "attributeName1": "颜色",
        "attributeValue1": "黄色",
        "attributeName2": "尺寸1",
        "attributeValue2": "L",
        "skuCode": "12",
        "skuName": "雪碧1",
        "price": 12,
        "isShelf": "上架"
    }
]

想组成这样的数据:

let arr2 =[
    {
        "id": "e34d1a87-a9ed-42ab-97ed-8b60765af929",
        "parentId": "2490ad9e-96b5-4bcd-a846-076c097b2eec",
        "skuName": "黄色",
        "remarks": "",
        "check": true
    },
    {
        "id": "a3f2c0dd-d464-44ad-ada0-c561d2913014",
        "parentId": "2490ad9e-96b5-4bcd-a846-076c097b2eec",
        "skuName": "白色",
        "remarks": "",
        "check": false
    },
    {
        "id": "e1754005-f794-4717-9241-887617a9866b",
        "parentId": "2490ad9e-96b5-4bcd-a846-076c097b2eec",
        "skuName": "红色",
        "remarks": "",
        "check": false
    },
    {
        "id": "b974f217-a802-4540-b6eb-7898393acb5d",
        "parentId": "2490ad9e-96b5-4bcd-a846-076c097b2eec",
        "skuName": "紫色",
        "remarks": "",
        "check": false
    }
]

  • 写回答

6条回答

      报告相同问题?

      相关推荐 更多相似问题

      问题事件

      • 系统已结题 10月2日
      • 已采纳回答 9月24日
      • 创建了问题 9月24日

      悬赏问题

      • ¥15 VS2019不能设置QT的verson了,设置了点确定又消失了,怎么解决呢?
      • ¥15 用java解决,要解释一下给我
      • ¥100 项目经理想学开发牛牛指点迷津有偿
      • ¥15 vscode 配置时出现问题
      • ¥15 pygame安装失败
      • ¥15 数据库原理怎么从文字描述中的句子推出(分析)函数依赖?
      • ¥15 想要使用有序logistic模型,因变量收集结果为以下,可以继续分析吗?
      • ¥15 C语言的问题 求尽快解答一下
      • ¥15 sql相关子查询的一道选择题
      • ¥15 关于图像检测的问题#