在对象遍历中去字符串截取某个字段然后赋值给这个字段的坑

此坑比较大

场景:

vue子组件拿父组件的传值,[{},{}]结构的,父组件为2014-02-04 03:55:33,子组件需要过滤改变为02-04 03:55:33

filterDataAddClassName(list) {
      let _this = this;
      if (Object.keys(list).length > 0) {
        return list.map(item => {
          item.cellClassName = {
            id: `level-class-style-${item.alarmLevel}`
          };
          // item.callTime = item.callTime.substring(5);
          // console.log(item.callTime);
          let nTime = item.callTime.substring(5);
          item.NewCallTime = nTime;
          return item;
        });
      }
    },

正常写法为注释

但是这样会出现一个问题,可能是相同内存的递归???反正会一直截取字符串,不明白为什么

但是我用了一个新值去放这个处理的,就ok了

原文地址:https://www.cnblogs.com/lsc-boke/p/11351830.html