From 8c9902e2a0c8571a73af65f6f4041f6b4d2a589d Mon Sep 17 00:00:00 2001 From: Oliver <1069035666@qq.com> Date: Fri, 25 Mar 2022 08:00:25 +0000 Subject: [PATCH] =?UTF-8?q?=E8=99=9A=E6=8B=9F=E5=88=97=E8=A1=A8=20?= =?UTF-8?q?=E4=B8=80=E7=9B=B4=20=E6=BB=9A=E5=8A=A8=E5=88=B0=E6=9C=80?= =?UTF-8?q?=E5=BA=95=E9=83=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../VirtualScroll/src/VirtualScroll.vue | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/src/components/VirtualScroll/src/VirtualScroll.vue b/src/components/VirtualScroll/src/VirtualScroll.vue index b37a058..6eb5874 100644 --- a/src/components/VirtualScroll/src/VirtualScroll.vue +++ b/src/components/VirtualScroll/src/VirtualScroll.vue @@ -22,6 +22,10 @@ minHeight: [Number, String] as NumberOrNumberString, minWidth: [Number, String] as NumberOrNumberString, width: [Number, String] as NumberOrNumberString, + scrollToBottom: { + type: Boolean as PropType, + default: true, + }, bench: { type: [Number, String] as NumberOrNumberString, default: 0, @@ -103,6 +107,19 @@ onScroll(); }); + watch( + () => props.items.length, + () => { + if (props.scrollToBottom) { + const wrapEl = unref(wrapElRef); + if (!wrapEl) { + return; + } + wrapEl.scrollTop = (props.items || []).length * unref(getItemHeightRef); + } + }, + ); + function getLast(first: number): number { const wrapEl = unref(wrapElRef); if (!wrapEl) { -- Gitee