ant-design/components/dropdown/demo/selectable.md

56 lines
889 B
Markdown

---
order: 13
title:
zh-CN: 菜单可选选择
en-US: Selectable Menu
---
## zh-CN
添加 `menu` 中的 `selectable` 属性可以开启选择能力。
## en-US
Configure the `selectable` property in `menu` to enable selectable ability.
```tsx
import { DownOutlined } from '@ant-design/icons';
import type { MenuProps } from 'antd';
import { Dropdown, Space, Typography } from 'antd';
import React from 'react';
const items: MenuProps['items'] = [
{
key: '1',
label: 'Item 1',
},
{
key: '2',
label: 'Item 2',
},
{
key: '3',
label: 'Item 3',
},
];
const App: React.FC = () => (
<Dropdown
menu={{
items,
selectable: true,
defaultSelectedKeys: ['3'],
}}
>
<Typography.Link>
<Space>
Selectable
<DownOutlined />
</Space>
</Typography.Link>
</Dropdown>
);
export default App;
```