diff --git a/packages/vantui/src/tabs/index.tsx b/packages/vantui/src/tabs/index.tsx index 7281f3e3..32cd0623 100644 --- a/packages/vantui/src/tabs/index.tsx +++ b/packages/vantui/src/tabs/index.tsx @@ -210,7 +210,7 @@ export function Tabs(props: TabsProps) { getAllRect(null, `.tabs-com-index${indexRef.current} .van-tab`), getRect(null, `.tabs-com-index${indexRef.current} .van-tabs__nav`), ]).then(([tabRects, navRect]: any) => { - if (tabRects && navRect) { + if (tabRects && tabRects.length && navRect) { const tabRect = tabRects[index!] const offsetLeft = tabRects .slice(0, index) @@ -311,7 +311,9 @@ export function Tabs(props: TabsProps) { useEffect( function () { nextTick(() => { - scrollIntoView() + setTimeout(() => { + scrollIntoView() + }, 33) }) if (active !== getCurrentName() && !ref.current?.swiping && !swipeable) { setCurrentIndexByName(active)