JS对数组对象里面的key进行重新编辑

/**

  • this.tempData为数组
  • item 遍历出来的对象
    */
    this.tempData.forEach(item => {
    let obj = item;
    for (let key in obj) {
    var temp = key.replace(/-/g, ''); //把有-划线的key,全部替换成下划线
    obj[temp] = obj[key];
    delete obj[key];
    }
    })
    for (let key in this.tempData[0].vct_TaskReportInfo) {
    var temp = key.replace(/-/g, '
    ');
    this.tempData[0].vct_TaskReportInfo[temp] = this.tempData[0].vct_TaskReportInfo[key];
    delete this.tempData[0].vct_TaskReportInfo[key];
    }

你可能感兴趣的:(JS对数组对象里面的key进行重新编辑)