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 | 控制打开状态 | boolean | false |
title | 确认标题 | string | 必填 |
description | 确认说明 | string | — |
destroy-on-close | 退场后卸载内容 | boolean | false |
destructive | 使用危险操作样式 | boolean | false |
confirm-text / cancel-text | 操作按钮文案 | string | '确认' / '取消' |
loading | 阻止重复确认和关闭 | boolean | false |
confirm-disabled | 禁用确认按钮 | boolean | false |
事件
| 事件 | 说明 |
|---|---|
update:modelValue | 用户关闭时在 closed 后回写 false |
confirm | 点击确认时触发,由调用方完成操作并关闭 |
cancel | 点击取消按钮时触发 |
open / close | 打开 / 关闭开始 |
opened | 入场动画完成 |
closed | 退出动画完成后触发,可执行必要的业务收尾 |
插槽
| 插槽 | 说明 |
|---|---|
default | 补充确认内容 |