美文网首页
JS对数组对象里面的key进行重新编辑

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

作者: 海染蓝了天 | 来源:发表于2020-05-26 20:42 被阅读0次

/**

  • 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进行重新编辑

      本文链接:https://www.haomeiwen.com/subject/sylmahtx.html