Skip to content

KLDialog

考拉弹窗组件

效果

vue
<script setup lang="ts">
import { ref, inject } from 'vue';
import DialogCom from './DialogCom.vue';
const klDialog = inject<Function>('klDialog') as Function;

const showDialog = ref(false);
function openDialog() {
  klDialog(DialogCom, {
    title: '注入方式',
  });
}
</script>

<template>
  <div class="wh-full">
    <KLButton content="注入方式" class="mr30" @click="openDialog" />
    <KLButton content="显示/隐藏弹窗" @click="showDialog = !showDialog" />
    <KLDialog v-model:showDialog="showDialog" title="显示/隐藏弹窗" canMove>
      <template #main>
        <div class="flex-center hl-color" style="width: 500px;height:300px;font-size:100px;">
          <KLIcon name="plc-1" />
          <KLIcon name="plc" class="ml30" />
        </div>
      </template>
    </KLDialog>
  </div>
</template>
vue
<script setup lang="ts">
defineProps<{
  title: string;
}>()
</script>

<template>
  <KLDialog :title="title" canMove>
    <template #main>
      <div class="flex-center hl-color" style="width: 500px;height:300px;font-size:100px;">
        <KLIcon name="plc-1" />
        <KLIcon name="plc" class="ml30" />
      </div>
    </template>
  </KLDialog>
</template>

Attributes

属性说明类型默认值
title弹窗标题string-
width宽度string|number-
height高度string|number-
full是否全屏boolean-
footer是否显示页脚booleantrue
canMove是否可以移动弹窗组件boolean-
close关闭按钮回调函数,返回值为是否阻止关闭弹窗() => boolean-
sure确认按钮回调函数,返回值为是否阻止关闭弹窗() => boolean-
cancel取消按钮回调函数,返回值为是否阻止关闭弹窗() => boolean-
sureFirstfooter确认按钮与取消按钮交换位置boolean-

slot

插槽名说明数据
header头部-
main主体-
footer尾部{hiddenDialog: () => void}