ant design pro 无二级菜单,且进入所属二级菜单及其他子菜单高亮显示
此处,list是默认显示的菜单栏,add页面是子菜单。我们要实现进入add页面的时候,也高亮显示左边,实现效果看3.效果图
关键
hideChildrenInMenu: 当前路由的子级在菜单中不展现,默认 false
父的path要和默认显示子的path保持一致
add 的path不需要’/’,作用为了,将add添加到path中,实际的path为’/user-list/add’
1.route.ts目录结构
2.配置
{
name: 'user',
icon: 'table',
path: '/user-list',
hideChildrenInMenu: true,
routes:[
{
name: 'list',
icon: 'table',
path: '/user-list',
component: './SettingMange',
},
{
name: 'add',
icon: 'table',
path: 'add',
component: './SettingMange/Components/CreateForm',
},
]
},
zh-CN 菜单栏英文名对应显示的中文名
menu.ts
export default {
'menu.user': '我的账户',
'menu.user.list': '我的账户列表',
'menu.user.add': '新增账户',
}
3.效果图