ant-design-vue/components/modal/demo/manual.vue
Cherry7 9be58078d2
Refactor(demo): change options to composition api (#6499)
* 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
2023-04-28 14:08:21 +08:00

42 lines
903 B
Vue

<docs>
---
order: 6
title:
zh-CN: 手动更新和移除
en-US: Manual to update destroy
---
## zh-CN
手动更新和关闭 `Modal.method` 方式创建的对话框
## en-US
Manually updating and destroying a modal from `Modal.method`.
</docs>
<template>
<a-button @click="countDown">Open modal to close in 5s</a-button>
</template>
<script lang="ts" setup>
import { Modal } from 'ant-design-vue';
const countDown = () => {
let secondsToGo = 5;
const modal = Modal.success({
title: 'This is a notification message',
content: `This modal will be destroyed after ${secondsToGo} second.`,
});
const interval = setInterval(() => {
secondsToGo -= 1;
modal.update({
content: `This modal will be destroyed after ${secondsToGo} second.`,
});
}, 1000);
setTimeout(() => {
clearInterval(interval);
modal.destroy();
}, secondsToGo * 1000);
};
</script>