获取树结构表头的所有字段

方法:递归获取

下面这张是我写项目的时候的截图

    getChildrenIndex(currentColumns) {
      console.log('currentColumns', currentColumns)
      for (var i = 0; i < currentColumns.length; i++) {
        let item = currentColumns[i]
        if (item.children) {
          this.getChildrenIndex(item.children)
        } else {
          this.curColumnList.push(item.dataIndex)
        }
      }
    },

 currentColumns是树结构表头数据

思想:每次递归之前把数组清空,然后往里面push递归的每一项的dataIndex,dataIndex就是表头字段名称

猜你喜欢

转载自blog.csdn.net/weixin_47039061/article/details/128254549
今日推荐