Skip to content

Dialog 对话框 ​

通过 v-model 控制显隐,支持标题、自定义内容与 footer。

基础用法 ​

vue
<script setup lang="ts">
import { ref } from 'vue'
const visible = ref(false)
</script>

<template>
  <KbButton type="primary" @click="visible = true">打开对话框</KbButton>
  <KbDialog v-model="visible" title="确认操作">
    <p>这是对话框内容</p>
    <template #footer>
      <KbButton @click="visible = false">取消</KbButton>
      <KbButton type="primary" @click="visible = false">确定</KbButton>
    </template>
  </KbDialog>
</template>

API ​

属性类型默认值说明
modelValuebooleanfalse是否显示
titlestring''标题
widthstring | number480宽度(数字为 px)
closeOnClickOverlaybooleantrue点击遮罩关闭

插槽 ​

名称说明
default内容区
footer底部操作区

事件 ​

事件说明
update:modelValue关闭时触发
close点击遮罩关闭时触发