首页 > 编程语言 >element-ui tree数据中根据id查找node

element-ui tree数据中根据id查找node

时间:2023-02-11 14:57:06浏览次数:42  
标签:node findNode tree list element result null id

  1. 递归返回正确数据
  2. 尽早返回
  3.  findNode(list, id) {
          let result = null
          for (let i = 0; i < list.length; i++) {
            if (list[i].ID === id) {
              result = list[i]
              console.log('selected', result)
              break
            } else {
              const node = this.findNode(list[i].Children, id)
              if (node != null) {
                result = node
                break
              }
            }
          }
    
          return result
        },

     

标签:node,findNode,tree,list,element,result,null,id
From: https://www.cnblogs.com/wellma/p/17111652.html

相关文章