老白菜菜

导航

快速将数组对象的key转换成驼峰格式

const camelCase = require('camelcase'); // npm 驼峰格式小工具

arr= arr.map((obj) => {
      const newObj = {};
      Object.keys(obj).forEach((key) => {
        newObj[camelCase(key)] = obj[key];
      });
      return newObj;
    });

 

posted on 2022-06-06 16:17  老白菜菜  阅读(199)  评论(0编辑  收藏  举报