antd4.x drawer文档 https://ant.design/components/drawer-cn
import React from 'react';
import PropTypes from 'prop-types';
import { Drawer, Button } from 'antd';
DrawerEdit.propTypes = {
onSubmit: PropTypes.func.isRequired,
onClose: PropTypes.func.isRequired,
visible: PropTypes.bool,
title: PropTypes.string,
width: PropTypes.number,
};
DrawerEdit.defaultProps = {
visible: false,
title: '编辑',
width: 480,
};
function DrawerEdit(props) {
const { children, visible, title, width, onClose, onSubmit } = props;
const attr = {
title,
visible,
width,
// size: 'large', // @4.17
closable: false,
// onClose,
headerStyle: {padding: 16},
bodyStyle: {padding: 16},
footerStyle: {display: 'flex'},
footer: [
<Button
key='submit'
htmlType='submit'
className="mr16"
type="primary"
block
onClick={onSubmit}
>
确定
</Button>,
<Button
key='cancel'
onClick={() => onClose(false)}
block
>
取消
</Button>
]
}
return (
<Drawer {...attr}>{children}</Drawer>
)
}
export default DrawerEdit;