Skip to content

ConfirmDialog 确认弹窗 ​

在执行操作前请求确认。

基础用法 ​

监听 confirm 执行操作,成功后将 v-model 设为 false。

查看代码收起代码
vue
<script setup lang="ts">
import { ZButton, ZConfirmDialog } from '@codex-proxy/ui'
import { shallowRef } from 'vue'

const open = shallowRef(false)
const confirmations = shallowRef(0)
function confirm() {
  confirmations.value++
  open.value = false
}
</script>

<template>
  <div class="demo-row">
    <ZButton type="danger" variant="plain" @click="open = true">
      移除示例项
    </ZButton>
    <output aria-label="确认次数">已确认 {{ confirmations }} 次</output>
    <ZConfirmDialog v-model="open" title="移除示例项" description="此操作只更新演示计数,不会修改真实数据" destructive confirm-text="移除" @confirm="confirm" />
  </div>
</template>

ConfirmDialog API ​

属性 ​

属性说明类型默认值
v-model控制打开状态booleanfalse
title确认标题string必填
description确认说明string—
destroy-on-close退场后卸载内容booleanfalse
destructive使用危险操作样式booleanfalse
confirm-text / cancel-text操作按钮文案string'确认' / '取消'
loading阻止重复确认和关闭booleanfalse
confirm-disabled禁用确认按钮booleanfalse

事件 ​

事件说明
update:modelValue用户关闭时在 closed 后回写 false
confirm点击确认时触发,由调用方完成操作并关闭
cancel点击取消按钮时触发
open / close打开 / 关闭开始
opened入场动画完成
closed退出动画完成后触发,可执行必要的业务收尾

插槽 ​

插槽说明
default补充确认内容