Skip to content
On this page

Dialog 对话框

基础使用

vue
<template>
  <k-button
    type="primary" size="large"
    @click="visible = true"
  >
    打开对话框
  </k-button>
  <k-dialog v-model="visible">
    这是一个对话框
  </k-dialog>
</template>

<script setup>
import { ref } from 'vue';

const visible = ref(false);
</script>

隐藏底部

设置show-footer, 可显示隐藏底部

vue
<template>
  <k-button
    type="primary" size="large"
    @click="visible = true"
  >
    隐藏底部按钮
  </k-button>
  <k-dialog v-model="visible" :show-footer="false">
    这是一个没有底部的对话框
  </k-dialog>
</template>

<script setup>
import { ref } from 'vue';

const visible = ref(false);
</script>

自定义底部

使用插槽footer, 可自定义底部

vue
<template>
  <k-button
    type="primary" size="large"
    @click="visible = true"
  >
    自定义底部按钮
  </k-button>
  <k-dialog v-model="visible">
    这是一个没有底部的对话框
    <template #footer>
      <k-button>自定义按钮</k-button>
    </template>
  </k-dialog>
</template>

<script setup>
import { ref } from 'vue';

const visible = ref(false);
</script>

内容居中

center设置为true即可使标题和底部居中

vue
<template>
  <k-button
    type="primary" size="large"
    @click="visible = true"
  >
    内容居中
  </k-button>
  <k-dialog v-model="visible" center>
    这是一个内容居中的对话框
  </k-dialog>
</template>

<script setup>
import { ref } from 'vue';

const visible = ref(false);
</script>

Dialog 属性

Dialog 事件

Dialog slots

WARNING

如果Iframe模式下,有父级弹框的时候调用,其他模式请忽略

开启默认调用 parent.window.postMessage('openMask()', '*'); window.top.postMessage('openMask()', '*');

关闭默认调用 parent.window.postMessage('closeMask()', '*'); window.top.postMessage('closeMask()', '*');