useImperativeAlertDialog
@astryxdesign/core v0.7.1 · useImperativeAlertDialog
返回值
| 名称 | 类型 | 说明 |
|---|---|---|
show | (options: ImperativeAlertDialogOptions) => void | 按给定配置弹出对话框。配置就是 AlertDialog 的属性去掉 isOpen,再加上 onAction。 |
hide | () => void | 关掉对话框。 |
isOpen | Ref<boolean> | 对话框当前是否打开。 |
Host | Component | 承载对话框的组件。在模板里渲染一次:<component :is="alert.Host" />。 |
配置项
| 名称 | 类型 | 默认值 | 说明 |
|---|---|---|---|
title | string | — | 要问的问题,通过 aria-labelledby 成为对话框的名字。必填。 |
description | string | — | 确认之后会发生什么,通过 aria-describedby 和对话框关联,读屏会一起念出来。必填。 |
actionLabel | string | — | 确认按钮的文字。写清楚会发生什么,例如 'Delete project'。必填。 |
onAction | (event: MouseEvent) => void | — | 确认动作被触发时调用。对话框不会自己关:事情办完你自己调 hide()。 |
cancelLabel | string | 'Cancel' | 取消按钮的文字。 |
actionVariant | AlertDialogActionVariant | 'destructive' | 确认按钮的视觉样式。 |
isActionLoading | boolean | false | 确认动作还在跑的时候,在按钮上显示转圈。 |
width | number | string | 400 | 期望宽度。数字按像素,字符串原样使用。 |