You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
ant-design-vue/components/popconfirm/demo/promise.vue

39 lines
846 B

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

<docs>
---
order: 7
version: 3.0
title:
zh-CN: 基于 Promise 的异步关闭 (3.0+)
en-US: Asynchronously close on Promise (3.0+)
---
## zh-CN
点击确定后异步关闭 Popconfirm例如提交表单
## en-US
Asynchronously close a popconfirm when the OK button is pressed. For example, you can use this pattern when you submit a form.
</docs>
<template>
<a-popconfirm title="Title" @confirm="confirm" @cancel="cancel">
<a-button type="primary">Open Popconfirm with Promise</a-button>
</a-popconfirm>
</template>
<script lang="ts" setup>
import { message } from 'ant-design-vue';
const confirm = (e: MouseEvent) => {
console.log(e);
return new Promise(resolve => {
setTimeout(() => resolve(true), 3000);
});
};
const cancel = (e: MouseEvent) => {
console.log(e);
message.error('Click on No');
};
</script>