学无先后,达者为师

网站首页 前端文档 正文

JavaScript entries() 方法,取到数组中对象的key、value

作者:LMYH1123 更新时间: 2022-01-12 前端文档

entries() 方法返回一个数组的迭代对象,该对象包含数组的键值对 (key/value)。

迭代对象中数组的索引值作为 key, 数组元素作为 value。

 console.log(newColumns,'newColumns')
  for (let [index, item] of newColumns.entries()) {
      console.log(index,'----------------',item)
      this.columns.splice(4 + index, 0, item)
   }
newColumns=[
    {
        "title": "评分1",
        "dataIndex": "1"
    },
    {
        "title": "评分2",
        "dataIndex": "2"
    },
    {
        "title": "评分3",
        "dataIndex": "3"
    },
    {
        "title": "评分4",
        "dataIndex": "4"
    }]

原文链接:https://blog.csdn.net/lmyh1111/article/details/122104604

栏目分类
最近更新