js循环修改数组属性key值


var keyMap = {
            deviceUid: "id",
            deviceType: "typeName",
            deviceCode: "code",
            deviceName: "name",
            deviceStatus: "status"
          };
          for (var i = 0; i < data.confList.length; i++) {
            var obj = data.confList[i];
            for (var key in obj) {
              var newKey = keyMap[key];
              if (newKey) {
                obj[newKey] = obj[key];
                delete obj[key];
              }
            }
          }
          console.log("array", data.confList);

或者重新建一个[]

然后重新push

let itemArr = [];
      this.deviceTableData_ys_true.map(item => {
        itemArr.push({
          deviceUid: item.id,
          deviceId: item.deviceId
        });
      });

 


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM