修改对象的键

    let t = [{
        name:"王五",
        age:28,
        sex:"man"
    },
    {
        name:"王yi",
        age:30,
        sex:"man"
    },
    {
        name:"王san",
        age:5,
        sex:"man"
    }
    ]
    let newData = t.map(item => {
        return {
          templateId: item.name,
          designList: item.age,
          sex:item.sex
        }
      })
    console.log(newData);

结果为:

 

posted @ 2021-06-28 10:23  奔跑的哈密瓜  阅读(72)  评论(0编辑  收藏  举报