-
Notifications
You must be signed in to change notification settings - Fork 7.3k
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
请教这样的动态路由菜单怎么配置? #3543
Comments
@klgd 看不懂上面描述 |
这是tools的路由配置 |
@klgd 你可以试试(改官方示例测试):
// 略...
import { LAYOUT } from '@/router/constant';
// 略...
export const asyncRoutes = [
PAGE_NOT_FOUND_ROUTE,
...routeModuleList,
// 添加第一层路由测试
{
// 一级菜单
path: '/testTab',
name: 'TestTabRoot',
component: LAYOUT,
meta: {
orderNo: 0,
title: '工具',
},
children: [
{
// 二级菜单
path: ':id',
name: 'TestTab', // 对应 defineOptions 的 name,获得 keep-alive 效果
component: () => import('@/views/demo/feat/tab-params/index.vue'),
meta: {
// 页面需要使用 useTabs 的 setTitle 修改 title 为 “TestTab1”、“TestTab2”
title: 'TestTab',
hideMenu: true, // 不显示为菜单
},
},
// ignoreRoute: true,意味着下面仅仅是菜单,不是路由
// 真实路由是 /testTab/:id
{
path: '/testTab/id1',
meta: {
title: 'TestTab1',
ignoreRoute: true,
},
},
{
path: '/testTab/id2',
meta: {
title: 'TestTab2',
ignoreRoute: true,
},
},
],
},
];
// 略... |
对对对,就是这样,困扰了我好久,还是对这个项目理解不够,原来还可以不用指定 component,ignoreRoute这个参数之前确实没注意到 @xachary 非常感谢 |
This issue is stale because it has been open 60 days with no activity. Remove stale label or comment or this will be closed in 7 days |
菜单样式:
一级菜单 /tools
-- 二级菜单1 /tools/abc
-- 二级菜单2 /tools/def
二级菜单 都是动态路由
tools/:id
的带参菜单跟官方demo中的tab带参类似,但是我像实现的是二级菜单而不是像Tab带参那样的三级菜单
请问该如何配置路由?
The text was updated successfully, but these errors were encountered: