diff --git a/src/hooks/useVirtualScrollNew.ts b/src/hooks/useVirtualScrollNew.ts index afb98b1d68..4ca901f219 100644 --- a/src/hooks/useVirtualScrollNew.ts +++ b/src/hooks/useVirtualScrollNew.ts @@ -171,7 +171,7 @@ const useVirtualScroll = (container: Ref, params: UseVirtual const refreshVirtualScroll = ([{ contentRect }]: [ResizeObserverEntry]) => { // 如果宽度发生变化,重置滚动位置 const maxScrollbarWidth = 16; - if (Math.abs(contentRect.width - containerWidth.value) > maxScrollbarWidth) { + if (Math.abs(contentRect.width - containerWidth.value) > maxScrollbarWidth && !!container.value) { container.value.scrollTop = 0; translateY.value = 0; }