Arry字符串变Object对象字段名

Arry字符串变Object对象字段名:

//数组
[
    {
        "bmc": "sys_portal_role",
        "bmczw": "模块入口角色",
        "sfzb": 1,
        "bid": "1480350856666939393",
        "glzj": null,
        "glb": null,
        "glwj": null,
        "glbds": null,
        "sort": 0
    },
    {
        "bmc": "bs_tree_dic_data",
        "bmczw": "树形字典数据",
        "sfzb": 0,
        "bid": "1486889354133839873",
        "glzj": null,
        "glb": null,
        "glwj": null,
        "glbds": null,
        "sort": 1
    },
    {
        "bmc": "amt_audit_bsjdw_leader",
        "bmczw": "经责领导人单位关系表",
        "sfzb": 0,
        "bid": "1490519238506651650",
        "glzj": null,
        "glb": null,
        "glwj": null,
        "glbds": null,
        "sort": 2
    }
]

//function
 changeObject() {
      console.log(this.tabItems, "this.tabItems");
      let obj = {};
      let arrs = JSON.parse(JSON.stringify(this.tabItems));
      arrs.forEach((item, i) => {
        delete item.bid;
        delete item.sort;
        obj[item.bmc] = item;
      });
      this.tapObj = obj;
      console.log(obj, "obj");
    },

//obj 打印出的结果,把表名当做字段名
{
    "sys_portal_role": {
        "bmc": "sys_portal_role",
        "bmczw": "模块入口角色",
        "sfzb": 1,
        "glzj": null,
        "glb": null,
        "glwj": null,
        "glbds": null
    },
    "bs_tree_dic_data": {
        "bmc": "bs_tree_dic_data",
        "bmczw": "树形字典数据",
        "sfzb": 0,
        "glzj": null,
        "glb": null,
        "glwj": null,
        "glbds": null
    },
    "amt_audit_bsjdw_leader": {
        "bmc": "amt_audit_bsjdw_leader",
        "bmczw": "经责领导人单位关系表",
        "sfzb": 0,
        "glzj": null,
        "glb": null,
        "glwj": null,
        "glbds": null
    }
}
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

唐飞滚滚

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值