Skip to content

对话框 Dialog ​

自研对话框,<teleport to="body"> 渲染,遮罩点击/右上角 × 关闭。

Props

属性类型默认值说明
modelValuebooleanfalse是否显示(v-model)
titlestring''标题
widthstring | number'50%'宽度;数字自动转 px,字符串原样(如 '500px')

事件

事件参数说明
update:modelValueboolean关闭(遮罩/×)时触发

Slots

插槽说明
默认对话框内容
footer底部按钮区(有插槽才渲染)

示例

vue
<template>
  <Button @click="visible = true">打开弹窗</Button>
  <Dialog v-model="visible" title="确认操作" width="420px">
    <p>确定要执行该操作吗?</p>
    <template #footer>
      <Button @click="visible = false">取消</Button>
      <Button variant="destructive" @click="confirm">确认</Button>
    </template>
  </Dialog>
</template>

Released under the MIT License.