2017-11-26 14:02:00 +08:00
|
|
|
---
|
|
|
|
order: 8
|
|
|
|
title:
|
|
|
|
zh-CN: 右键菜单
|
|
|
|
en-US: Context Menu
|
|
|
|
---
|
|
|
|
|
|
|
|
## zh-CN
|
|
|
|
|
2018-09-07 14:03:17 +08:00
|
|
|
默认是移入触发菜单,可以点击鼠标右键触发。
|
2017-11-26 14:02:00 +08:00
|
|
|
|
|
|
|
## en-US
|
|
|
|
|
2018-09-07 14:03:17 +08:00
|
|
|
The default trigger mode is `hover`, you can change it to `contextMenu`.
|
2017-11-26 14:02:00 +08:00
|
|
|
|
2022-05-19 09:46:26 +08:00
|
|
|
```tsx
|
2022-05-23 14:37:16 +08:00
|
|
|
import { Dropdown, Menu } from 'antd';
|
2022-05-19 09:46:26 +08:00
|
|
|
import React from 'react';
|
2017-11-26 14:02:00 +08:00
|
|
|
|
|
|
|
const menu = (
|
2022-03-18 15:20:35 +08:00
|
|
|
<Menu
|
|
|
|
items={[
|
|
|
|
{
|
|
|
|
label: '1st menu item',
|
|
|
|
key: '1',
|
|
|
|
},
|
|
|
|
{
|
|
|
|
label: '2nd menu item',
|
|
|
|
key: '2',
|
|
|
|
},
|
|
|
|
{
|
|
|
|
label: '3rd menu item',
|
|
|
|
key: '3',
|
|
|
|
},
|
|
|
|
]}
|
|
|
|
/>
|
2017-11-26 14:02:00 +08:00
|
|
|
);
|
|
|
|
|
2022-05-19 09:46:26 +08:00
|
|
|
const App: React.FC = () => (
|
2017-11-26 14:02:00 +08:00
|
|
|
<Dropdown overlay={menu} trigger={['contextMenu']}>
|
2019-12-10 11:37:32 +08:00
|
|
|
<div
|
2019-12-26 14:48:29 +08:00
|
|
|
className="site-dropdown-context-menu"
|
2019-12-10 11:37:32 +08:00
|
|
|
style={{
|
|
|
|
textAlign: 'center',
|
|
|
|
height: 200,
|
|
|
|
lineHeight: '200px',
|
|
|
|
}}
|
|
|
|
>
|
|
|
|
Right Click on here
|
|
|
|
</div>
|
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
|
|
|
```
|
2019-12-26 14:48:29 +08:00
|
|
|
|
|
|
|
```css
|
|
|
|
.site-dropdown-context-menu {
|
|
|
|
color: #777;
|
2021-01-30 19:39:02 +08:00
|
|
|
background: #f7f7f7;
|
2019-12-26 14:48:29 +08:00
|
|
|
}
|
|
|
|
```
|
|
|
|
|
|
|
|
<style>
|
|
|
|
[data-theme="dark"] .site-dropdown-context-menu {
|
|
|
|
background: #141414;
|
|
|
|
color: rgba(255,255,255,.65);
|
|
|
|
}
|
|
|
|
</style>
|