ContextMenu

阅读时间约 1 分钟

上下文菜单。

import { Menu, ContextMenu } from '@antv/x6-react-components'
import '@antv/x6-react-components/es/menu/style/index.css'
import '@antv/x6-react-components/es/dropdown/style/index.css'
import '@antv/x6-react-components/es/context-menu/style/index.css'

const menu = (
  <Menu>
    <Menu.Item key="1">1st menu item</Menu.Item>
    <Menu.Item key="2">2nd menu item</Menu.Item>
    <Menu.Item key="3">3rd menu item</Menu.Item>
  </Menu>
)

<ContextMenu menu={menu}>
  <div
    style={{
      width: 560,
      height: 240,
      display: 'flex',
      justifyContent: 'center',
      alignItems: 'center',
      background: '#f5f5f5',
      userSelect: 'none',
    }}
  >
    Right Click On Me
  </div>
</ContextMenu>

ContextMenu

参数说明类型默认值
className自定义的样式名string-
menu菜单 Menu 组件Menu-
overlayClassName下拉根元素的类名称string-
overlayStyle下拉根元素的样式CSSProperties-
disabled菜单是否禁用booleanfalse
visible菜单是否显示booleanfalse
getPopupContainer菜单渲染父节点。默认渲染到 body 上,如果你遇到菜单滚动定位问题,试试修改为滚动的区域,并相对其定位。(triggerNode: Element) => HTMLElement-
onVisibleChange菜单显示状态改变时调用(visible?: boolean) => void-