Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

如何实现集成父级路由参数的子路由呢? #11047

Closed
wuchencm opened this issue Nov 20, 2023 · 2 comments
Closed

如何实现集成父级路由参数的子路由呢? #11047

wuchencm opened this issue Nov 20, 2023 · 2 comments

Comments

@wuchencm
Copy link

🥰 需求描述 | Requirements description

如下:
image
image
image
红色部分的路由都是基于蓝色部分

我当前使用的版本是ant design pro v6

@chenshuai2144
Copy link
Collaborator

可以用 wrappers来进行这种操作,wrappers 中可以用 Outlet 拿到当前的路由

import { Navigate, Outlet } from 'umi'

export default (props) => {
  const { isLogin } = useAuth();
  if (isLogin) {
    return <Outlet />;
  } else{
    return <Navigate to="/login" />;
  }
}

https://umijs.org/docs/guides/routes#wrappers

@wuchencm
Copy link
Author

wuchencm commented Nov 21, 2023

{
path:'/devops/:appName',
name:'devops',
routes: [

  {
    name:'appOverview',
    path: '/devops/:appName/overview',
    component: './Devops/index',
    icon: 'WindowsOutlined',
    wrappers: [
      '@/wrappers/devops',
    ],
  },

}

这是我的配置,代码也是按照你上面给的,可是单独点击子菜单的时候,url里还是展示的是appName参数,而不是值呢

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants