cjd-parkball
Version:
> 中后台业务组件库,中后台就像公园,进入需要买门票(登录),所以以 Parkball(公园球) 命名,公园内必定捕获!作为一个组件库,提供使用方法文档,方便开发者的调用
40 lines (31 loc) • 895 B
Markdown
---
category: 2
title: 确认对话框
title_en: Confirmation modal dialog
---
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.
````jsx
import { Modal, Button } from 'parkball';
const confirm = Modal.confirm;
function showConfirm() {
confirm({
title: 'Do you want to delete these items?',
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!'));
},
onCancel() {},
});
}
ReactDOM.render(
<Button onClick={showConfirm}>
Confirm
</Button>,
mountNode);
````