1.js 前端将平级数据转为树形数据的方法

转,实测成功

https://segmentfault.com/a/1190000022444269

    // 将同级数据转化为树形结构
    listToTree(dataSource) {
// datasource是平级的数据来源
      return dataSource.filter(e => {
        const pid = e.parentId
        const resultArr = dataSource.filter(ele => {
          if (ele.menuId === pid) {
            if (!ele.children) {
              ele.children = []
            }
            ele.children.push(e)
            return true
          }
        })
        return resultArr.length === 0
      })
    },

 

2. element-ui 树形结构的table,如何改变小箭头所在的列,默认在第一列数据上。

https://segmentfault.com/q/1010000019098934/revision

 

修改的话,就将第一列的type改为'', 如果你在第三列展开,前面2列全部为空

真的搜索了好久才找到办法

相关文章:

  • 2021-07-15
  • 2021-08-06
  • 2022-12-23
  • 2021-09-25
  • 2022-01-09
猜你喜欢
  • 2021-08-26
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-07-21
  • 2021-07-18
  • 2022-12-23
相关资源
相似解决方案