处理触底加载更多
This commit is contained in:
@@ -47,7 +47,7 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
.location-position {
|
.location-position {
|
||||||
max-width: 66%;
|
max-width: 58%;
|
||||||
white-space: nowrap;
|
white-space: nowrap;
|
||||||
overflow: hidden;
|
overflow: hidden;
|
||||||
text-overflow: ellipsis;
|
text-overflow: ellipsis;
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ import ListLoadError from "@/components/ListLoadError";
|
|||||||
import ListCardSkeleton from "@/components/ListCardSkeleton";
|
import ListCardSkeleton from "@/components/ListCardSkeleton";
|
||||||
import { useReachBottom } from "@tarojs/taro";
|
import { useReachBottom } from "@tarojs/taro";
|
||||||
import "./index.scss";
|
import "./index.scss";
|
||||||
|
import { useRef, useEffect } from "react";
|
||||||
|
|
||||||
const ListContainer = (props) => {
|
const ListContainer = (props) => {
|
||||||
const {
|
const {
|
||||||
@@ -14,12 +15,23 @@ const ListContainer = (props) => {
|
|||||||
// recommendList,
|
// recommendList,
|
||||||
loadMoreMatches,
|
loadMoreMatches,
|
||||||
} = props;
|
} = props;
|
||||||
|
const timerRef = useRef<NodeJS.Timeout | null>(null);
|
||||||
|
|
||||||
useReachBottom(() => {
|
useReachBottom(() => {
|
||||||
// 加载更多方法
|
// 加载更多方法
|
||||||
loadMoreMatches();
|
timerRef.current = setTimeout(() => {
|
||||||
|
loadMoreMatches();
|
||||||
|
}, 500);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
return () => {
|
||||||
|
if (timerRef.current) {
|
||||||
|
clearTimeout(timerRef.current);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}, []);
|
||||||
|
|
||||||
if (error) {
|
if (error) {
|
||||||
return <ListLoadError reload={reload} />;
|
return <ListLoadError reload={reload} />;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user