js递归树

// 递归算法找usedept对应名称
    traverseCodeToName(treelist, udCode) {
      if (!treelist) {
        return;
      }
      for (let index = 0; index < treelist.length; index++) {
        if (treelist[index].code == udCode) {
          this.travUdNameTemp = treelist[index].name;
          return;
        }
        if (treelist[index].children != undefined && treelist[index].children.length > 0) {
          this.traverseCodeToName(treelist[index].children, udCode);
        }
      }
    },
发布了18 篇原创文章 · 获赞 9 · 访问量 2万+

猜你喜欢

转载自blog.csdn.net/xueyue616/article/details/83826508