eg:

let tableData=[{name:'小明',age:'12'},{name:'小红',age:'11'}]

//遍历数组对象增加属性 index

如果直接遍历的话对象会有__ob__: Observer属性,这些数据是vue这个框架对数据设置的监控器,一般都是不可枚举的,因此要转换下类型:

let _Data = JSON.parse(JSON.stringify(tableData))
此刻再遍历
  _Data.forEach((e, index) => {
            e.index = index
    })

枚举说明:https://www.jianshu.com/p/01a8ae8ac62c

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2021-10-27
  • 2021-06-08
  • 2022-01-12
  • 2021-07-15
  • 2022-12-23
猜你喜欢
  • 2021-09-30
  • 2021-11-04
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案