1. import React from 'react';
    2. import PropTypes from 'prop-types';
    3. import { Empty } from 'antd';
    4. import styles from './style.module.less';
    5. const LedaoEmpty = (props) => {
    6. const {text, height, width} = props;
    7. return (
    8. <Empty
    9. className={styles.emptyData}
    10. style={{height, width}}
    11. description={text}
    12. />
    13. );
    14. };
    15. LedaoEmpty.propTypes = {
    16. text: PropTypes.string,
    17. height: PropTypes.string,
    18. width:PropTypes.string,
    19. };
    20. LedaoEmpty.defaultProps = {
    21. text: '暂无数据',
    22. height:'100%',
    23. width: '100%',
    24. };
    25. export default LedaoEmpty;
    26. // css样式
    27. .emptyData {
    28. display: flex:
    29. width: 100%;
    30. height: 100%,
    31. flex-direction:column;
    32. align-items: center;
    33. justify-content: center;
    34. padding-bottom: 24px;
    35. box-sizing: border-box;
    36. }
    37. // 用法 -- react写法
    38. _.isEmpty([]) ? <LedaoEmpty height='616px' width='100%' />
    39. : null;