修复空间Tab切换
This commit is contained in:
parent
556ef80e5e
commit
9192651354
|
@ -51,6 +51,7 @@ export default function Space() {
|
|||
}, []);
|
||||
useEffect(() => {
|
||||
firstRequest();
|
||||
setDataList([]);
|
||||
}, [activeIndex]);
|
||||
const firstRequest = () => {
|
||||
resetOffset();
|
||||
|
@ -65,7 +66,6 @@ export default function Space() {
|
|||
};
|
||||
const resetOffset = () => {
|
||||
setOffset(0);
|
||||
// setDataList([]);
|
||||
};
|
||||
const getSpaceList = async () => {
|
||||
// setLoading(true);
|
||||
|
@ -136,7 +136,7 @@ export default function Space() {
|
|||
onChange={(key) => {
|
||||
const index = tabItems.findIndex((item) => item.key === key);
|
||||
setActiveIndex(index);
|
||||
// swiperRef.current?.swipeTo(index);
|
||||
swiperRef.current?.swipeTo(index);
|
||||
}}
|
||||
>
|
||||
{tabItems.map((item) => (
|
||||
|
@ -155,17 +155,18 @@ export default function Space() {
|
|||
<OwnIcon src="/icons/search.png" className="w-9 h-9" />
|
||||
</Link>
|
||||
</div>
|
||||
{}
|
||||
<Swiper
|
||||
direction="horizontal"
|
||||
indicator={() => null}
|
||||
// ref={swiperRef}
|
||||
ref={swiperRef}
|
||||
defaultIndex={activeIndex}
|
||||
allowTouchMove={false}
|
||||
onIndexChange={(index) => {
|
||||
setActiveIndex(index);
|
||||
}}
|
||||
>
|
||||
<Swiper.Item>
|
||||
{!activeIndex && (
|
||||
<div>
|
||||
{!loading ? (
|
||||
// <div className="px-4 pb-8">
|
||||
|
@ -249,10 +250,8 @@ export default function Space() {
|
|||
</div>
|
||||
)}
|
||||
</div>
|
||||
)}
|
||||
</Swiper.Item>
|
||||
<Swiper.Item>
|
||||
{!!activeIndex && (
|
||||
<div className="px-4 pb-20">
|
||||
<List className="scrollbarBox_hidden">
|
||||
{loading && !dataList.length && (
|
||||
|
@ -289,7 +288,6 @@ export default function Space() {
|
|||
</div>
|
||||
)} */}
|
||||
</div>
|
||||
)}
|
||||
</Swiper.Item>
|
||||
</Swiper>
|
||||
<div
|
||||
|
|
Loading…
Reference in New Issue