antd4.x drawer文档 https://ant.design/components/drawer-cn
    image.png

    1. import React from 'react';
    2. import PropTypes from 'prop-types';
    3. import { Drawer, Button } from 'antd';
    4. DrawerEdit.propTypes = {
    5. onSubmit: PropTypes.func.isRequired,
    6. onClose: PropTypes.func.isRequired,
    7. visible: PropTypes.bool,
    8. title: PropTypes.string,
    9. width: PropTypes.number,
    10. };
    11. DrawerEdit.defaultProps = {
    12. visible: false,
    13. title: '编辑',
    14. width: 480,
    15. };
    16. function DrawerEdit(props) {
    17. const { children, visible, title, width, onClose, onSubmit } = props;
    18. const attr = {
    19. title,
    20. visible,
    21. width,
    22. // size: 'large', // @4.17
    23. closable: false,
    24. // onClose,
    25. headerStyle: {padding: 16},
    26. bodyStyle: {padding: 16},
    27. footerStyle: {display: 'flex'},
    28. footer: [
    29. <Button
    30. key='submit'
    31. htmlType='submit'
    32. className="mr16"
    33. type="primary"
    34. block
    35. onClick={onSubmit}
    36. >
    37. 确定
    38. </Button>,
    39. <Button
    40. key='cancel'
    41. onClick={() => onClose(false)}
    42. block
    43. >
    44. 取消
    45. </Button>
    46. ]
    47. }
    48. return (
    49. <Drawer {...attr}>{children}</Drawer>
    50. )
    51. }
    52. export default DrawerEdit;