mirror of
https://github.com/ant-design/ant-design.git
synced 2024-12-24 07:28:28 +08:00
87 lines
1.5 KiB
Markdown
87 lines
1.5 KiB
Markdown
---
|
|
order: 3
|
|
title:
|
|
zh-CN: 确认对话框
|
|
en-US: Confirmation modal dialog
|
|
---
|
|
|
|
## zh-CN
|
|
|
|
使用 `confirm()` 可以快捷地弹出确认框。
|
|
|
|
## en-US
|
|
|
|
To use `confirm()` to popup a confirmation modal dialog.
|
|
|
|
````jsx
|
|
import { Modal, Button } from 'antd';
|
|
|
|
const confirm = Modal.confirm;
|
|
|
|
function showConfirm() {
|
|
confirm({
|
|
title: 'Do you Want to delete these items?',
|
|
content: 'Some descriptions',
|
|
onOk() {
|
|
console.log('OK');
|
|
},
|
|
onCancel() {
|
|
console.log('Cancel');
|
|
},
|
|
});
|
|
}
|
|
|
|
function showDeleteConfirm() {
|
|
confirm({
|
|
title: 'Are you sure delete this task?',
|
|
content: 'Some descriptions',
|
|
okText: 'Yes',
|
|
okType: 'danger',
|
|
cancelText: 'No',
|
|
onOk() {
|
|
console.log('OK');
|
|
},
|
|
onCancel() {
|
|
console.log('Cancel');
|
|
},
|
|
});
|
|
}
|
|
|
|
function showPropsConfirm() {
|
|
confirm({
|
|
title: 'Are you sure delete this task?',
|
|
content: 'Some descriptions',
|
|
okText: 'Yes',
|
|
okType: 'danger',
|
|
maskClosable: true,
|
|
okButtonProps: {
|
|
disabled: true,
|
|
},
|
|
cancelButtonProps: {
|
|
loading: true,
|
|
},
|
|
cancelText: 'No',
|
|
onOk() {
|
|
console.log('OK');
|
|
},
|
|
onCancel() {
|
|
console.log('Cancel');
|
|
},
|
|
});
|
|
}
|
|
|
|
ReactDOM.render(
|
|
<div>
|
|
<Button onClick={showConfirm}>
|
|
Confirm
|
|
</Button>
|
|
<Button onClick={showDeleteConfirm} type="dashed">
|
|
Delete
|
|
</Button>
|
|
<Button onClick={showPropsConfirm} type="dashed">
|
|
With extra props
|
|
</Button>
|
|
</div>,
|
|
mountNode);
|
|
````
|