// 例子根据name字段来搜索
handleTreeData = (treeData, searchValue) => {
    if (!treeData || treeData.length === 0) {
      return [];
    }
    const array = [];
    for (let i = 0; i < treeData.length; i += 1) {
      if (this.handleTreeData(treeData[i].children, searchValue).length > 0 || treeData[i].name.includes(searchValue)) {
        array.push({
          ...treeData[i],
          children: this.handleTreeData(treeData[i].children, searchValue),
        });
      }
    }
    return array;
  }

相关文章:

  • 2021-09-17
  • 2022-12-23
  • 2021-11-21
  • 2021-09-04
  • 2022-12-23
  • 2021-07-07
  • 2021-07-13
猜你喜欢
  • 2021-11-25
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-12-26
相关资源
相似解决方案