Skip to content

Dialog 对话框 ​

在保留当前页面状态的情况下,告知用户并承载相关操作。

基础用法 ​

Dialog 弹出一个对话框,适合需要定制性更大的场景。

TIP

before-close 只会在用户点击关闭按钮或者对话框的遮罩区域时被调用。 如果你在 footer 具名插槽里添加了用于关闭 Dialog 的按钮,那么可以在按钮的点击回调函数里加入 before-close 的相关逻辑。

自定义头部 ​

嵌套的对话框 ​

如果需要在一个 Dialog 内部嵌套另一个 Dialog,需要使用 append-to-body 属性。

可拖拽对话框 ​

试着拖动一下header部分吧

TIP

当设置 modal 属性为 false 时,请将 append-to-body 属性设置为 true,因为 Dialog 是通过 position: relative 来确定位置的。一旦移除了 modal 属性,Dialog 会基于当前的 DOM 元素来进行定位, 而不是基于 document.body,这会导致样式问题。

属性 ​

AttributeDescriptionTypeAccepted ValuesDefault
model-value / v-modelvisibility of Dialogboolean——
titletitle of Dialog. Can also be passed with a named slot (see the following table)string——
widthwidth of Dialogstring / number—50%
fullscreenwhether the Dialog takes up full screenboolean—false
topvalue for margin-top of Dialog CSSstring—15vh
modalwhether a mask is displayedboolean—true
append-to-bodywhether to append Dialog itself to body. A nested Dialog should have this attribute set to trueboolean—false
lock-scrollwhether scroll of body is disabled while Dialog is displayedboolean—true
custom-classcustom class names for Dialogstring——
open-delayTime(milliseconds) before opennumber—0
close-delayTime(milliseconds) before closenumber—0
close-on-click-modalwhether the Dialog can be closed by clicking the maskboolean—true
close-on-press-escapewhether the Dialog can be closed by pressing ESCboolean—true
show-closewhether to show a close buttonboolean—true
before-closecallback before Dialog closes, and it will prevent Dialog from closingfunction(done),done is used to close the Dialog——
draggableenable dragging feature for Dialogboolean—false
centerwhether to align the header and footer in centerboolean—false
destroy-on-closeDestroy elements in Dialog when closedboolean—false

插槽 ​

NameDescription
—content of Dialog
headercontent of the Dialog header
footercontent of the Dialog footer

事件 ​

Event NameDescriptionParameters
opentriggers when the Dialog opens—
openedtriggers when the Dialog opening animation ends—
closetriggers when the Dialog closes—
closedtriggers when the Dialog closing animation ends—
open-auto-focustriggers after Dialog opens and content focused—
close-auto-focustriggers after Dialog closed and content focused—

Released under the MIT License.