2018-12-03 17:08:48 +08:00
---
order: 8
title:
zh-CN: 销毁确认对话框
en-US: destroy confirmation modal dialog
---
## zh-CN
2018-12-03 21:49:00 +08:00
使用 `Modal.destroyAll()` 可以销毁弹出的确认窗。通常用于路由监听当中,处理路由前进、后退不能销毁确认对话框的问题。
2018-12-03 17:08:48 +08:00
## en-US
2018-12-03 21:49:00 +08:00
`Modal.destroyAll()` could destroy all confirmation modal dialogs. Usually, you can use it in router change event to destroy confirm modal dialog automatically
2018-12-03 17:08:48 +08:00
```jsx
import { Modal, Button } from 'antd';
2018-12-23 18:40:11 +08:00
function destroyAll() {
2018-12-03 21:49:00 +08:00
Modal.destroyAll();
2018-12-23 18:40:11 +08:00
}
2018-12-03 17:08:48 +08:00
const confirm = Modal.confirm;
function showConfirm() {
2018-12-23 18:40:11 +08:00
for (let i = 0; i < 3 ; i + = 1 ) {
setTimeout(() => {
confirm({
content: (
< Button onClick = {destroyAll} >
Click to destroy all
< / Button >
),
onOk() {
console.log('OK');
},
onCancel() {
console.log('Cancel');
},
});
}, i * 500);
}
2018-12-03 17:08:48 +08:00
}
ReactDOM.render(
< div >
< Button onClick = {showConfirm} > Confirm< / Button >
< / div > , mountNode
);
```