Snackbar
Snackbar 组件用于通知用户应用程序已执行或将要执行的操作。
useSnackbar API
导入
import { useSnackbar } from '@mui/base/useSnackbar';
// or
import { useSnackbar } from '@mui/base';
通过阅读关于最小化包大小的指南,了解更多差异。
名称 | 类型 | 默认值 | 描述 |
---|---|---|---|
autoHideDuration | number | null | null | 等待自动调用 |
disableWindowBlurListener | boolean | false | 如果为 |
onClose | (event: React.SyntheticEvent<any> | Event | null, reason: SnackbarCloseReason) => void | - | 当组件请求关闭时触发的回调函数。通常 |
open | boolean | - | 如果为 |
resumeHideDuration | number | - | 用户交互后等待多少毫秒才关闭。如果未指定 |
名称 | 类型 | 描述 |
---|---|---|
getRootProps | <ExternalProps extends Record<string, unknown> = {}>(externalProps?: ExternalProps) => UseSnackbarRootSlotProps<ExternalProps> | 根插槽 props 的解析器。 |
onClickAway | (event: React.SyntheticEvent<any> | Event) => void | 当检测到“点击外部”事件时触发的回调函数。 |