vue路由递归查找某路径

hasRoute(path, routeList) {
      // console.log('path', path, routeList);
      for (let i = 0; i < routeList.length; i++) {
        if (routeList[i].path === path) {
          return true;
        }
        if (routeList[i].children) {
          let flag = this.hasRoute(path, routeList[i].children);
          if (flag) {
            return flag;
          }
        }
      }
      return false;
    },
posted @ 2023-05-30 15:21  sinceForever  阅读(72)  评论(0编辑  收藏  举报