| | |
| | | ); |
| | | }; |
| | | |
| | | const menuList = [ |
| | | { |
| | | "name": '列表页面', |
| | | "path": "/path1", |
| | | "component": Hello |
| | | }, |
| | | // ...其它项 |
| | | ] |
| | | const route = { |
| | | route: { |
| | | path: '/', |
| | | routes: menuList |
| | | routes: [ |
| | | { |
| | | name: '列表页', |
| | | path: '/list', |
| | | component: './ListTableList', |
| | | routes: [ |
| | | { |
| | | path: '/list/sub-page', |
| | | name: '列表页面', |
| | | routes: [ |
| | | { |
| | | path: 'sub-sub-page1', |
| | | name: '一级列表页面', |
| | | component: './Hello', |
| | | }, |
| | | { |
| | | path: 'hello', |
| | | name: '你好世界', |
| | | component: 'Hello', |
| | | }, |
| | | ], |
| | | }, |
| | | ], |
| | | }, |
| | | ] |
| | | }, |
| | | location: { |
| | | pathname: '/', |
| | | }, |
| | | } |
| | | |
| | | console.log(route); |
| | | console.log(defaultProps); |
| | | const menu0 = [ |
| | | { |
| | | "path": "/path2", |
| | | "component": Hello |
| | | } |
| | | ] |
| | | |
| | | export default () => { |
| | | if (typeof document === 'undefined') { |
| | |
| | | width: '331px', |
| | | }, |
| | | ]} |
| | | {...defaultProps} |
| | | {...route} |
| | | location={{ |
| | | pathname, |
| | | }} |
| | |
| | | menuItemRender={(item, dom) => ( |
| | | <div |
| | | onClick={() => { |
| | | setPathname(item.path || '/welcome'); |
| | | console.log(dom); |
| | | setPathname(item.path); |
| | | }} |
| | | > |
| | | {dom} |
| | |
| | | {/* <G6></G6> */} |
| | | <PageContainer> |
| | | <Routes> |
| | | <Route path="/list/sub-page/hello" element={<Hello />} /> |
| | | {/* 根据实际路由继续添加更多的 Route */} |
| | | {menu0.map(item => |
| | | <Route key={item.path} path={item.path} element={React.createElement(item.component)} /> |
| | | )} |
| | | </Routes> |
| | | {/* <G6></G6> */} |
| | | </PageContainer> |