UNPKG

2.21 kBMarkdownView Raw
1# @ant-design/pro-layout
2
3![](https://gw.alipayobjects.com/zos/antfincdn/HSeAGqaEwn/1586504755352-479bf47d-97a6-4080-afed-d38ffe905e57.png)
4
5ProLayout provides a standard, yet flexible, middle and backend layout, with one-click layout switching and automatic menu generation. It can be used with PageContainer to automatically generate breadcrumbs, page headers, and provide a low-cost solution to access the footer toolbar.
6
7## When to use
8
9ProLayout can be used to reduce layout costs when content needs to be carried on a page.
10
11### Use with umi plugins
12
13ProLayout works best with umi. umi automatically injects the routes from config.ts into the configured layout for us, so we don't have to write the menus by hand.
14
15ProLayout extends umi's router configuration, adding name, icon, locale, hideInMenu, hideChildrenInMenu and other configurations, so that it is easier to generate menus in one place. The data format is as follows.
16
17```ts | pure
18export interface MenuDataItem {
19 /** @name submenu */
20 children?: MenuDataItem[];
21 /** @name Hide child nodes in the menu */
22 hideChildrenInMenu?: boolean;
23 /** @name hideSelf and children in menu */
24 hideInMenu?: boolean;
25 /** @name Icon of the menu */
26 icon?: React.ReactNode;
27 /** @name Internationalization key for custom menus */
28 locale?: string | false;
29 /** @name The name of the menu */
30 name?: string;
31 /** @name is used to calibrate the selected value, default is path */
32 key?: string;
33 /** @name disable menu option */
34 disabled?: boolean;
35 /** @name path */
36 path?: string;
37 /**
38 * When this node is selected, the node of parentKeys is also selected
39 *
40 * @name custom parent node
41 */
42 parentKeys?: string[];
43 /** @name hides itself and elevates child nodes to its level */
44 flatMenu?: boolean;
45
46 [key: string]: any;
47}
48```
49
50ProLayout will automatically select the menu based on `location.pathname` and automatically generate the corresponding breadcrumbs. If you don't want to use it, you can configure `selectedKeys` and `openKeys` yourself for controlled configuration.
51
52## Install
53
54Using npm:
55
56```bash
57$ npm install --save @ant-design/pro-layout
58```
59
60or using yarn:
61
62```bash
63$ yarn add @ant-design/pro-layout
64```