import React from 'react'; import { Spin } from 'antd'; import { LoadingOutlined } from '@ant-design/icons'; import styles from './index.less'; import VisibilitySensor from 'react-visibility-sensor'; import classNames from '@pansy/classnames'; export enum LoadState { isLoading = 'isLoading', noMore = 'noMore', isFailed = 'isFailed' } interface IProps { loadState: LoadState; onChange: (isVisible: boolean) => void; } // 外层容器最好设置 flex 布局,此时数据为空是 空白站位图片及文字才能垂直居中显示,否则将显示在容器顶部 const LoadMoreList = (props: IProps) => { const { loadState, onChange } = props; function getLoadContent() { if (loadState == LoadState.isFailed) { return (
加载失败, { onChange(true); }} > 重新加载
); } else if (loadState === LoadState.noMore) { return
没有更多了
; } else if (loadState === LoadState.isLoading) { return (
加载中 } />
); } else { return; } } return (
{getLoadContent()}
); }; export default LoadMoreList;