跳转到内容
Ctrl+K

ClickAwayListener API

API documentation for the React ClickAwayListener component. Learn about the available props, and the CSS API.

Import

import ClickAwayListener from '@material-ui/core/ClickAwayListener';
// 或
import { ClickAwayListener } from '@material-ui/core';
You can learn about the difference by reading this guide on minimizing bundle size.

Listen for click events that occur somewhere in the document, outside of the element itself. For instance, if you need to hide a menu when people click anywhere else on your page.

属性

名称类型默认值描述
children*elementThe wrapped element.
⚠️ Needs to be able to hold a ref.
onClickAway*funcCallback fired when a "click away" event is detected.
disableReactTreeboolfalseIf true, the React tree is ignored and only the DOM tree is considered. This prop changes how portaled elements are handled.
mouseEvent'onClick'
| 'onMouseDown'
| 'onMouseUp'
| false
'onClick'The mouse event to listen to. You can disable the listener by providing false.
touchEvent'onTouchEnd'
| 'onTouchStart'
| false
'onTouchEnd'The touch event to listen to. You can disable the listener by providing false.

The component cannot hold a ref.

Demos


CircularProgress
这个页面是否有用?
Collapse
感谢您的反馈 !

请让我们知道我们可以做些什么来改善这个页面。