diff --git a/src/components/VirtualScroll/src/VirtualScroll.vue b/src/components/VirtualScroll/src/VirtualScroll.vue index b37a0587dcb2ec07ff67973bc0141e4b1431779d..6eb58745da33f93a873cce353fb9262d79425387 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) {