diff --git a/packages/web-vue/components/_components/virtual-list-v2/virtual-list.vue b/packages/web-vue/components/_components/virtual-list-v2/virtual-list.vue index 166dd9762..9d99a9ea9 100644 --- a/packages/web-vue/components/_components/virtual-list-v2/virtual-list.vue +++ b/packages/web-vue/components/_components/virtual-list-v2/virtual-list.vue @@ -165,15 +165,6 @@ export default defineComponent({ buffer, }); - const shouldScroll = ref(true); - const scrollData = reactive({ - scrollTop: 0, - scrollHeight: 0, - }); - // 数据发生修改 - watch(dataKeys, () => { - shouldScroll.value = false; - }); const currentList = computed(() => { if (props.threshold && data.value.length <= props.threshold) { return data.value; @@ -185,27 +176,17 @@ export default defineComponent({ const onScroll = (ev: Event) => { const { scrollTop, scrollHeight, offsetHeight } = ev.target as HTMLElement; - if (shouldScroll.value) { - scrollData.scrollTop = scrollTop; - scrollData.scrollHeight = scrollHeight; - const _start = getStartByScroll(scrollTop); - if (_start !== start.value) { - setStart(_start); - } - emit('scroll', ev); - const bottom = Math.floor(scrollHeight - (scrollTop + offsetHeight)); - if (bottom <= 0) { - emit('reachBottom', ev); - } - } else { - // 数据发生修改完成 (是否采用MutationObserver) - if (scrollHeight !== scrollData.scrollHeight) { - shouldScroll.value = true; - setTimeout(() => { - scrollTo(scrollData.scrollTop); - }, 10); - } - scrollTo(scrollData.scrollTop); + const _start = getStartByScroll(scrollTop); + if (_start !== start.value) { + setStart(_start); + nextTick(() => { + scrollTo(scrollTop); + }); + } + emit('scroll', ev); + const bottom = Math.floor(scrollHeight - (scrollTop + offsetHeight)); + if (bottom <= 0) { + emit('reachBottom', ev); } };