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: 'home', label: '首页', path: '/' }, { key: 'staff', label: '人员总览', path: '/staff' }, { key: 'day', label: '日统计', path: '/daily' }, { key: 'month', label: '月统计', path: '/month' }, { key: 'year', label: '年度统计', path: '/year' } ]; return ( <> {/* 导航菜单 */} item.path === location.pathname)?.key, ]} > {menuItems.map((item) => ( navigate(item.path)} >
{item.label}
))}
); }