Skip to content

MessageBox 消息确认框 ​

命令式确认框,返回 Promise<boolean>。

基础用法 ​

异步关闭校验 ​

js
const confirmed = await AuMessageBox.confirm({
  title: '保存并发布',
  message: '确认提交当前版本吗?',
  async beforeClose(action) {
    if (action !== 'confirm') return true;
    return await validateRelease();
  },
});

MessageBox API ​

方法 ​

方法参数返回值说明
AuMessageBox(options)string / number / AuMessageBoxOptionsPromise<boolean>打开确认框
AuMessageBox.confirm(options)同上Promise<boolean>语义更明确的等价调用
AuMessageBox.close()—void关闭当前确认框并以 false 完成 Promise

Options ​

配置说明类型默认值
title标题string''
message正文string / number必填
width确认框宽度string / numbermin(420px, calc(100vw - 32px))
confirmButtonText确定按钮文案string确定
cancelButtonText取消按钮文案string取消
confirmTextconfirmButtonText 的兼容别名string—
cancelTextcancelButtonText 的兼容别名string—
confirmButtonType确定按钮的 AuButton 类型AuButtonTypeprimary
showCancelButton是否显示取消按钮booleantrue
showClose是否显示右上角关闭按钮booleantrue
closeLabel关闭按钮提示string关闭
closeOnClickModal是否允许点击遮罩关闭booleanfalse
closeOnPressEscape是否允许按 Escape 关闭booleantrue
beforeClose关闭前守卫(action, options) => boolean | Promise<boolean>—

Aurora Plus · Vue 3 Component Library