Dropdown
将动作或菜单折叠到下拉菜单中
基础用法
function App() {
const [visible, setVisible] = useState(false)
return (
<div className="ykui-demo-row">
<Dropdown
visible={visible}
onVisibleChange={(val) => setVisible(val)}
trigger="click"
usePortalWrapper={false}
overlay={
<div className="overlay">
<div>h1111111</div>
<div>h1111111</div>
</div>
}
>
<a href="#" onClick={(e) => e.preventDefault()}>click me</a>
</Dropdown>
</div>
);
}
Dropdown API
| 属性 | 说明 | 类型 | 默认值 |
|---|---|---|---|
| placement | 显示的位置 | placementEnum | bottom |
| visible | 是否显示 | boolean | false |
| container | 指定挂载的dom,默认为body | any | -- |
| trigger | 触发方式 | hover〡click〡focus | hover |
| overlay | 显示的组件 | Function〡ReactElement<any> | -- |
| style | 样式 | Object | -- |
| onHide | 面板关闭时调用 | Function | -- |
| operationButtons | 排除click outside的按钮 | any[] | -- |
| onVisibleChange | 显示或者隐藏的时候调用 | Function | -- |
| mouseEnterDelay | 显示弹窗延迟 | number | -- |
| mouseLeaveDelay | 关闭弹窗延迟 | number | left |
| children | 触发的元素 | ReactElement<any> | -- |
| autoFixedScroll | 自动监听滚动条滚动 | boolean | true |
| fixedWidth | panel宽度与trigger的宽度一致 | boolean | true |
placementEnum
placementEnum 的取值:
'bottomLeft' | 'bottom' | 'bottomRight' | 'topLeft' | 'top' | 'topRight' | 'left' | 'leftTop'
| 'leftBottom' | 'right' | 'rightTop' | 'rightBottom' | 'auto'