Skip to content

EMessageBox 消息弹窗 ​

import EUI 1.0

示例与代码 ​

消息弹窗 ​

QML 代码QML
效果
运行代码,体验组件交互

可修改文字、属性和事件,再点击运行。

代码在当前浏览器中运行 许可

属性 ​

属性说明取值与默认值
alignCenterbool

是否采用居中布局或居中文字。

默认值继承 Provider,默认 true
autofocusbool

组件显示时自动聚焦;受控件可用状态及弹层生命周期影响。

默认值true
backgroundColorcolor

背景颜色。

默认值动态绑定
beforeClosevar

关闭前回调;弹窗通过 done(cancel) 完成异步判断。

默认值function(action, instance, done) { done() }
borderColorcolor

边框颜色。

默认值动态绑定
buttonSizeint

操作按钮尺寸。

EStyle.Small
EStyle.Medium
EStyle.Large

默认值EStyle.Medium
callbackvar

消息框结果回调,接收操作类型和输入值。

默认值null
cancelButtonLoadingbool

取消或确认按钮是否显示加载状态。

默认值false
cancelButtonLoadingIconint

组件使用的图标。

EIcons.*
0(无图标)

默认值0
cancelStyleTypeint

语义配色风格。

EStyle.Default
EStyle.Primary
EStyle.Success
EStyle.Info
EStyle.Warning
EStyle.Danger

默认值EStyle.Default
cancelTextstring

取消按钮文字。

默认值随当前语言变化
centerbool

是否采用居中布局或居中文字。

默认值false
closeDelayint

等待、节流或自动关闭时间,单位为毫秒;0 表示不延迟或不启用定时关闭。

默认值0
closeIconint

组件使用的图标。

EIcons.*
0(无图标)

默认值EIcons.XMARK
closeOnClickOutsidebool

点击弹层外部时关闭。

默认值true
closeOnEscapebool

是否允许按 Escape 关闭。

默认值true
closePolicyenum

弹层自动关闭的触发条件,可组合多个条件。

Popup.*(可用 | 组合)
NoAutoClose
CloseOnPressOutside
CloseOnPressOutsideParent
CloseOnReleaseOutside
CloseOnReleaseOutsideParent
CloseOnEscape

默认值动态绑定
confirmButtonLoadingbool

取消或确认按钮是否显示加载状态。

默认值false
confirmButtonLoadingIconint

组件使用的图标。

EIcons.*
0(无图标)

默认值0
confirmStyleTypeint

语义配色风格。

EStyle.Default
EStyle.Primary
EStyle.Success
EStyle.Info
EStyle.Warning
EStyle.Danger

默认值EStyle.Primary
confirmTextstring

确认按钮文字。

默认值随当前语言变化
contentalias

内容插槽;直接在组件内部声明 QML 子对象。

默认值别名:dialogContent.data
contentComponentComponent

自定义主体内容的 Component 插槽;null 使用默认内容。 委托上下文见本页示例。

默认值null
dangerouslyUseHTMLStringbool

按富文本解释内容;仅应对可信内容启用。

默认值false
destroyOnClosebool

关闭后销毁通过 Component 加载的内容。

默认值false
dialogRadiusreal

圆角半径,单位为像素。

默认值8
distinguishCancelAndClosebool

区分取消按钮与其他关闭方式产生的结果。

默认值false
draggablebool

是否支持拖动;具体拖动对象由当前组件决定。

默认值继承 Provider,默认 false
enabledbool

是否允许交互;false 时控件禁用。

默认值true
enterDurationint

动画或显示持续时间,单位为毫秒;组件的绑定表达式给出实际用途。

默认值220
exitDurationint

动画或显示持续时间,单位为毫秒;组件的绑定表达式给出实际用途。

默认值180
focusbool

是否请求弹层焦点。

默认值autofocus
fullscreenbool

是否使用全屏显示或全窗口覆盖。

默认值false
heightreal

组件尺寸,单位为像素;可绑定父布局尺寸。

默认值fullscreen && Overlay.overlay ? Overlay.overlay.height : implicitHeight
iconSourceint

组件使用的图标。

EIcons.*
0(无图标)

默认值0
inputErrorMessagestring

消息框输入无效时的提示。

默认值""
inputPatternvar

消息框输入的正则校验规则。

默认值null
inputPlaceholderstring

空值时显示的占位文字。

默认值""
inputTypestring

消息框中的输入类型。

"text" / "textarea"
"password" / "number"
"email" / "tel"
"url"

默认值"text"
inputValidatorvar

自定义消息框输入校验函数,可返回布尔值或错误文字。

默认值null
inputValuestring

消息框输入的当前值。

默认值""
modalbool

使用模态弹层,阻止对下层内容的交互。

默认值true
modalOverlayColorcolor

模态或非模态遮罩颜色。

默认值动态绑定
modalPenetrablebool

是否允许输入穿透非模态遮罩。

默认值false
modelessOverlayColorcolor

模态或非模态遮罩颜色。

默认值动态绑定
openDelayint

等待、节流或自动关闭时间,单位为毫秒;0 表示不延迟或不启用定时关闭。

默认值0
overflowbool

是否允许对话框拖动超出窗口范围。

默认值继承 Provider,默认 false
roundButtonbool

采用圆角胶囊按钮样式。

默认值false
showCancelButtonbool

是否显示取消按钮。

默认值true
showClosebool

是否显示关闭或删除按钮。

默认值true
showConfirmButtonbool

是否显示确认按钮。

默认值true
showFooterbool

是否显示底部操作区。

默认值true
showHeaderbool

是否显示头部区域。

默认值true
showInputbool

显示数值输入或消息框输入区域。

默认值false
styleTypeint

语义配色风格。

EStyle.Default
EStyle.Primary
EStyle.Success
EStyle.Info
EStyle.Warning
EStyle.Danger

默认值EStyle.Default
textstring

显示的文字内容。

默认值""
textColorcolor

文字颜色。

默认值动态绑定
titlestring

标题文字。

默认值""
titleColorcolor

标题颜色。

默认值动态绑定
topreal

对话框顶部位置,单位为像素;非垂直居中时生效。

默认值0
visiblebool

是否显示组件。

默认值true
widthreal

组件尺寸,单位为像素;可绑定父布局尺寸。

默认值动态绑定
windowMarginreal

对话框与窗口边缘的最小间距,单位为像素。

默认值16
loadedContentalias只读

通过 Component 创建的实际内容对象。

默认值别名:contentLoader.item
loadedMessageContentalias只读

通过 Component 创建的实际内容对象。

默认值别名:messageContentLoader.item
maximumDialogWidthreal只读

扣除窗口边距后的对话框最大宽度。

默认值由运行时计算

信号 ​

签名作用
closeRejected()

关闭请求被 beforeClose 拒绝时触发。

openAutoFocused()

弹窗打开并完成自动聚焦时触发。

closeAutoFocused()

弹窗关闭并完成焦点恢复时触发。

canceled()

取消当前操作时触发。

confirmed(string value)

确认操作时触发;若有 value 参数,则为确认后的值。

completed(string action, string value)

消息框结束时触发,action 为结束操作,value 为输入内容。

方法 ​

签名作用
close()

关闭组件的面板或弹窗。

open()

打开组件的面板或弹窗。

resetPosition()

将对话框恢复到初始位置。

requestClose()

请求关闭弹窗,并执行 beforeClose 检查。

reject()

取消当前确认操作。

accept()

确认当前操作;输入不符合校验时不会提交。

alert(message, heading)

显示提示消息框,message 为内容,heading 为标题。

confirm(message, heading)

显示确认消息框,message 为内容,heading 为标题。

prompt(message, heading, initialValue)

显示输入消息框,message 为提示,heading 为标题,initialValue 为初始输入值。

基于 MIT 许可发布 · 第三方资源遵循其各自许可