diff --git a/src/components/VirtualScroll/src/VirtualScroll.vue b/src/components/VirtualScroll/src/VirtualScroll.vue index 255100327..12080cb70 100644 --- a/src/components/VirtualScroll/src/VirtualScroll.vue +++ b/src/components/VirtualScroll/src/VirtualScroll.vue @@ -52,7 +52,7 @@ export default defineComponent({ name: 'VirtualScroll', props, - setup(props, { slots }) { + setup(props, { slots, expose }) { const wrapElRef = ref(null); const state = reactive({ first: 0, @@ -128,6 +128,31 @@ state.last = getLast(state.first); } + function scrollToTop() { + const wrapEl = unref(wrapElRef); + if (!wrapEl) { + return; + } + wrapEl.scrollTop = 0; + } + + function scrollToBottom() { + const wrapEl = unref(wrapElRef); + if (!wrapEl) { + return; + } + wrapEl.scrollTop = wrapEl.scrollHeight; + } + + function scrollToItem(index: number) { + const wrapEl = unref(wrapElRef); + if (!wrapEl) { + return; + } + const i = index - 1 > 0 ? index - 1 : 0; + wrapEl.scrollTop = i * unref(getItemHeightRef); + } + function renderChildren() { const { items = [] } = props; return items.slice(unref(getFirstToRenderRef), unref(getLastToRenderRef)).map(genChild); @@ -143,6 +168,13 @@ ); } + expose({ + wrapElRef, + scrollToTop, + scrollToItem, + scrollToBottom, + }); + onMounted(() => { state.last = getLast(0); nextTick(() => { diff --git a/src/design/ant/input.less b/src/design/ant/input.less index 8245fb724..18a133ae7 100644 --- a/src/design/ant/input.less +++ b/src/design/ant/input.less @@ -4,8 +4,7 @@ .ant-input { &-number, &-number-group-wrapper { - width: 100% !important; - min-width: 110px; + width: 100%; max-width: 100%; } } diff --git a/src/views/demo/comp/scroll/VirtualScroll.vue b/src/views/demo/comp/scroll/VirtualScroll.vue index 69697e492..c3b146fd4 100644 --- a/src/views/demo/comp/scroll/VirtualScroll.vue +++ b/src/views/demo/comp/scroll/VirtualScroll.vue @@ -1,8 +1,26 @@