mirror of
https://gitee.com/ant-design-vue/ant-design-vue.git
synced 2024-12-05 05:29:01 +08:00
9be58078d2
* feat(demo): A-B * feat(demo): update B-checkbox * feat(demo): update CheckBox -DatePicker * feat(demo): update DatePicker - Form * feat(demo): update Form - List * feat(demo): update List-pagination * feat(demo): update List - skeleton * feat(demo): update skeleton - switch * feat(demo): update skeleton - switch * feat(demo): update switch - upload * feat(demo): update watermark * fix(demo): del hashId
42 lines
1.1 KiB
Vue
42 lines
1.1 KiB
Vue
<docs>
|
|
---
|
|
order: 9
|
|
title:
|
|
zh-CN: 确认对话框(promise)
|
|
en-US: Confirmation modal dialog use promise
|
|
---
|
|
|
|
## zh-CN
|
|
|
|
使用 `confirm()` 可以快捷地弹出确认框。onCancel/onOk 返回 promise 可以延迟关闭
|
|
|
|
## en-US
|
|
|
|
To use `confirm()` to popup confirmation modal dialog. Let onCancel/onOk function return a promise object to
|
|
delay closing the dialog.
|
|
|
|
</docs>
|
|
|
|
<template>
|
|
<a-button @click="showConfirm">Confirm</a-button>
|
|
</template>
|
|
<script lang="ts" setup>
|
|
import { ExclamationCircleOutlined } from '@ant-design/icons-vue';
|
|
import { createVNode } from 'vue';
|
|
import { Modal } from 'ant-design-vue';
|
|
const showConfirm = () => {
|
|
Modal.confirm({
|
|
title: 'Do you want to delete these items?',
|
|
icon: createVNode(ExclamationCircleOutlined),
|
|
content: 'When clicked the OK button, this dialog will be closed after 1 second',
|
|
onOk() {
|
|
return new Promise((resolve, reject) => {
|
|
setTimeout(Math.random() > 0.5 ? resolve : reject, 1000);
|
|
}).catch(() => console.log('Oops errors!'));
|
|
},
|
|
// eslint-disable-next-line @typescript-eslint/no-empty-function
|
|
onCancel() {},
|
|
});
|
|
};
|
|
</script>
|