2016-03-31 09:40:55 +08:00
|
|
|
---
|
2017-02-09 15:09:32 +08:00
|
|
|
order: 6
|
2016-07-04 10:48:21 +08:00
|
|
|
title:
|
|
|
|
zh-CN: 多级菜单
|
|
|
|
en-US: Cascading menu
|
2016-03-31 09:40:55 +08:00
|
|
|
---
|
2015-12-31 17:34:04 +08:00
|
|
|
|
2016-07-04 10:48:21 +08:00
|
|
|
## zh-CN
|
|
|
|
|
2015-12-31 17:34:04 +08:00
|
|
|
传入的菜单里有多个层级。
|
|
|
|
|
2016-07-04 10:48:21 +08:00
|
|
|
## en-US
|
|
|
|
|
|
|
|
The menu has multiple levels.
|
|
|
|
|
2022-05-19 09:46:26 +08:00
|
|
|
```tsx
|
|
|
|
import React from 'react';
|
2022-04-22 13:35:27 +08:00
|
|
|
import { Menu, Dropdown, Space } from 'antd';
|
2019-11-28 12:34:33 +08:00
|
|
|
import { DownOutlined } from '@ant-design/icons';
|
2018-06-27 15:55:04 +08:00
|
|
|
|
2016-01-07 16:29:12 +08:00
|
|
|
const menu = (
|
2022-03-18 15:20:35 +08:00
|
|
|
<Menu
|
|
|
|
items={[
|
|
|
|
{
|
2022-05-19 09:46:26 +08:00
|
|
|
key: '1',
|
2022-03-18 15:20:35 +08:00
|
|
|
type: 'group',
|
|
|
|
label: 'Group title',
|
|
|
|
children: [
|
|
|
|
{
|
2022-05-19 09:46:26 +08:00
|
|
|
key: '1-1',
|
2022-03-18 15:20:35 +08:00
|
|
|
label: '1st menu item',
|
|
|
|
},
|
|
|
|
{
|
2022-05-19 09:46:26 +08:00
|
|
|
key: '1-2',
|
2022-03-18 15:20:35 +08:00
|
|
|
label: '2nd menu item',
|
|
|
|
},
|
|
|
|
],
|
|
|
|
},
|
|
|
|
{
|
2022-05-19 09:46:26 +08:00
|
|
|
key: '2',
|
2022-03-18 15:20:35 +08:00
|
|
|
label: 'sub menu',
|
|
|
|
children: [
|
|
|
|
{
|
2022-05-19 09:46:26 +08:00
|
|
|
key: '2-1',
|
2022-03-18 15:20:35 +08:00
|
|
|
label: '3rd menu item',
|
|
|
|
},
|
|
|
|
{
|
2022-05-19 09:46:26 +08:00
|
|
|
key: '2-2',
|
2022-03-18 15:20:35 +08:00
|
|
|
label: '4th menu item',
|
|
|
|
},
|
|
|
|
],
|
|
|
|
},
|
|
|
|
{
|
2022-05-19 09:46:26 +08:00
|
|
|
key: '3',
|
2022-03-18 15:20:35 +08:00
|
|
|
label: 'disabled sub menu',
|
|
|
|
disabled: true,
|
|
|
|
children: [
|
|
|
|
{
|
2022-05-19 09:46:26 +08:00
|
|
|
key: '3-1',
|
2022-03-18 15:20:35 +08:00
|
|
|
label: '5d menu item',
|
|
|
|
},
|
|
|
|
{
|
2022-05-19 09:46:26 +08:00
|
|
|
key: '3-2',
|
2022-03-18 15:20:35 +08:00
|
|
|
label: '6th menu item',
|
|
|
|
},
|
|
|
|
],
|
|
|
|
},
|
|
|
|
]}
|
|
|
|
/>
|
2016-01-07 16:29:12 +08:00
|
|
|
);
|
2015-12-31 17:34:04 +08:00
|
|
|
|
2022-05-19 09:46:26 +08:00
|
|
|
const App: React.FC = () => (
|
2015-12-31 17:34:04 +08:00
|
|
|
<Dropdown overlay={menu}>
|
2022-04-22 13:35:27 +08:00
|
|
|
<a onClick={e => e.preventDefault()}>
|
|
|
|
<Space>
|
|
|
|
Cascading menu
|
|
|
|
<DownOutlined />
|
|
|
|
</Space>
|
2015-12-31 17:34:04 +08:00
|
|
|
</a>
|
2022-04-03 23:27:45 +08:00
|
|
|
</Dropdown>
|
2018-11-28 15:00:03 +08:00
|
|
|
);
|
2022-05-19 09:46:26 +08:00
|
|
|
|
|
|
|
export default App;
|
2019-05-07 14:57:32 +08:00
|
|
|
```
|