import React from 'react'; import ReactDOM from 'react-dom'; import classNames from 'classnames'; import assign from 'object-assign'; import Icon from '../icon'; import Dialog from './Modal'; import ActionButton from './ActionButton'; import { getConfirmLocale } from './locale'; export default function confirm(config) { const props = assign({ iconType: 'question-circle' }, config); const prefixCls = props.prefixCls || 'ant-confirm'; let div = document.createElement('div'); document.body.appendChild(div); let width = props.width || 416; let style = props.style || {}; // 默认为 false,保持旧版默认行为 const maskClosable = props.maskClosable === undefined ? false : props.maskClosable; // 默认为 true,保持向下兼容 if (!('okCancel' in props)) { props.okCancel = true; } const runtimeLocale = getConfirmLocale(); props.okText = props.okText || (props.okCancel ? runtimeLocale.okText : runtimeLocale.justOkText); props.cancelText = props.cancelText || runtimeLocale.cancelText; function close() { const unmountResult = ReactDOM.unmountComponentAtNode(div); if (unmountResult && div.parentNode) { div.parentNode.removeChild(div); } } let body = (