You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
import{ProLayout}from'@ant-design/pro-layout';import{Link,Outlet,useAppData,useLocation,useHistory}from'umi';exportdefaultfunctionLayout(){const{ clientRoutes }=useAppData();constlocation=useLocation();consthistory=useHistory();consthandleMenuClick=(path: string)=>{history.push(path);};return(<ProLayoutroute={clientRoutes[0]}location={location}title="Umi x Ant Design"menuItemRender={(menuItemProps,defaultDom)=>{if(menuItemProps.isUrl||menuItemProps.children){returndefaultDom;}if(menuItemProps.path&&location.pathname!==menuItemProps.path){return(<aonClick={()=>handleMenuClick(menuItemProps.path)}>{defaultDom}</a>);}returndefaultDom;}}><Outlet/></ProLayout>);}
🧐 问题描述 | Problem description
请问在ProLayout中的RunTimeLayoutConfig里通过传入menuProps的items属性来控制菜单的渲染后,如何同时绑定router处理路由跳转。
目前我想到的就是在menuProps里再传入onClick方法遍历route匹配menu的key 然后用history.push来操作,请问有更规范或者更符合设计的方式么
💻 示例代码 | Sample code
🚑 其他信息 | Other information
OS:
Node:
浏览器 | browser:
The text was updated successfully, but these errors were encountered: