Skip to content

Commit

Permalink
fix: power-scroll-view 组件大量 "null is not an object (evaluating \'t.sc…
Browse files Browse the repository at this point in the history
…rollTop\')" 错误

fix #476
  • Loading branch information
三少 committed Mar 21, 2023
1 parent 0c6a28b commit 11cf6a2
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
8 changes: 6 additions & 2 deletions packages/vantui/src/power-scroll-view/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -165,8 +165,12 @@ export function PowerScrollView<T extends number | undefined>(
}, [headHeight])

const getScrollTop = useCallback(async () => {
const { scrollTop } = await scrollOffset(scrollRef.current!)
return scrollTop
try {
const { scrollTop } = await scrollOffset(scrollRef.current!)
return scrollTop
} catch (error) {
return 0
}
}, [])

const isTouchable = useCallback(() => {
Expand Down
2 changes: 1 addition & 1 deletion packages/vantui/src/power-scroll-view/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ export function scrollOffset(nodesRef: TaroElement) {
return selectorQuery(nodesRef)
.scrollOffset()
.exec((res) => {
resolve(res[0])
resolve(res[0] || res)
})
})
}
Expand Down

0 comments on commit 11cf6a2

Please sign in to comment.