feat: first commit
This commit is contained in:
0
src/components/list-placeholder/index.less
Normal file
0
src/components/list-placeholder/index.less
Normal file
33
src/components/list-placeholder/index.tsx
Normal file
33
src/components/list-placeholder/index.tsx
Normal file
@ -0,0 +1,33 @@
|
||||
import { List, Loading } from '@taroify/core';
|
||||
import { ReactNode } from 'react';
|
||||
|
||||
import './index.less';
|
||||
|
||||
interface IPlaceholderProps {
|
||||
hasMore: boolean;
|
||||
loadingMore: boolean;
|
||||
loadMoreError: boolean;
|
||||
noMoreText: ReactNode;
|
||||
loadMoreErrorText: ReactNode;
|
||||
}
|
||||
|
||||
function ListPlaceholder(props: Partial<IPlaceholderProps>) {
|
||||
const { hasMore, loadingMore, loadMoreError, noMoreText, loadMoreErrorText } = props;
|
||||
|
||||
let content: ReactNode = '';
|
||||
if (loadingMore) {
|
||||
content = <Loading>加载中...</Loading>;
|
||||
} else if (loadMoreError) {
|
||||
content = loadMoreErrorText ?? '加载失败,请下拉刷新重试';
|
||||
} else if (!hasMore) {
|
||||
content = noMoreText ?? '没有更多了';
|
||||
}
|
||||
|
||||
if (!content) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return <List.Placeholder>{content}</List.Placeholder>;
|
||||
}
|
||||
|
||||
export default ListPlaceholder;
|
||||
Reference in New Issue
Block a user