vue项目侧边栏二级菜单只有一个时父级菜单不显示的问题

vue项目侧边栏菜单只有一个二级菜单时一级菜单消失

//遍历后台传来的路由字符串,转换为组件对象
function filterAsyncRouter(asyncRouterMap) {
  const accessedRouters = asyncRouterMap.filter((route) => {
    console.log("route", route);
    if (route.component) {
      if (route.component === "Main") {
        //Layout组件特殊处理
        route.component = Layout;
        route.alwaysShow = true;  //显示父级菜单
      } else if (route.component.startsWith("ExternLink")) {
        state.qlm_hash.add(route.path, route.component.substring(11));
        route.component = ExternLink;
      } else if (route.component === "App") {
        route.component = App;
      } else {
        route.component = _import(route.component);
      }
    } else {
      route.component = App;
    }

    if (route.children && route.children.length) {
      route.children = filterAsyncRouter(route.children);
    }
    return true;
  });
image.png

你可能感兴趣的:(vue项目侧边栏二级菜单只有一个时父级菜单不显示的问题)