题目

2023-09-06  本文已影响0人  志军_39e2

合并两个数据,合并完的值以arr2Target为主,arr2Target值为接口返回的 可能为null或者空数组,此时取值arr1

let arr1 = [
      {
        title: "效率",
        key: "eff",
        children: [
          {
            key: "a",
            title: "作业有效时长",
            component: "client",
            fixed: "left",
          },
          {
            key: "b",
            title: "首次作业效率",
            component: 'client',
            fixed: "left",
          },
        ],
      },
    ];
//接口返回的表头
    let arr2Target = [
      {
        title: "效率",
        key: "eff",
        children: [
          {
            key: "a",
            title: "作业有效时长",
            component: null,
            fixed: "right",
          },
          {
            key: "b",
            title: "首次作业效率",
            component: "server",
            fixed: "",
          },
          {
            key: "c",
            title: "ccc",
            component: 'server',
            fixed: "",
          },
        ],
      },
    ]
//输出结果
let result = [
    {
        "title": "效率",
        "key": "eff",
        "children": [
            {
                "key": "a",
                "title": "作业有效时长",
                "component": "client",
                "fixed": "right"
            },
            {
                "key": "b",
                "title": "首次作业效率",
                "component": "server",
                "fixed": ""
            },
            {
                "key": "c",
                "title": "ccc",
                "component": "server",
                "fixed": ""
            }
        ]
    }
]
上一篇 下一篇

猜你喜欢

热点阅读