import { Menu } from "antd"; import { useNavigate, useLocation } from "react-router-dom"; export default function NavigationMenu() { const navigate = useNavigate(); const location = useLocation(); console.log(location.pathname); // 导航菜单项配置 const menuItems = [ { key: 'staff', label: '人员总览', path: '/staff' }, { key: 'plan', label: '培训计划', path: '/plan' }, { key: 'day', label: '每日填报', path: '/daily' }, { key: 'exam', label: '考核成绩', path: '/exam' }, ]; return ( <> {/* 导航菜单 */} item.path === location.pathname)?.key, ]} > {menuItems.map((item) => ( navigate(item.path)} >
{item.label}
))}
); }