From 41d7be9f68c423012e2688fd45301300e9bb3dab Mon Sep 17 00:00:00 2001
From: Ben Lin <maobin001@msn.com>
Date: 星期二, 11 三月 2025 11:27:18 +0800
Subject: [PATCH] Merge branch 'master' of http://47.115.28.255:8110/r/TigerClouds-Tech/BS/TigerAdmin_2024

---
 src/views/demo/comp/scroll/VirtualScroll.vue |   39 +++++++++++++++++++++++++++------------
 1 files changed, 27 insertions(+), 12 deletions(-)

diff --git a/src/views/demo/comp/scroll/VirtualScroll.vue b/src/views/demo/comp/scroll/VirtualScroll.vue
index ba13287..c3b146f 100644
--- a/src/views/demo/comp/scroll/VirtualScroll.vue
+++ b/src/views/demo/comp/scroll/VirtualScroll.vue
@@ -1,8 +1,26 @@
 <template>
   <PageWrapper class="virtual-scroll-demo">
     <Divider>鍩虹婊氬姩绀轰緥</Divider>
+    <div class="text-center mb-4">
+      <a-button @click="vScrollRef?.scrollToTop()">婊氬姩鍒伴《閮�</a-button>
+      <a-button @click="vScrollRef?.scrollToBottom()" class="mx-2">婊氬姩鍒板簳閮�</a-button>
+      <a-button @click="vScrollRef?.scrollToItem(scrollToItemIndex)"
+        >婊氬姩鍒扮
+        <input-number
+          v-model:value="scrollToItemIndex"
+          class="!w-60px mx-1"
+          :min="1"
+          :max="data.length"
+          :precision="0"
+          size="small"
+          :controls="false"
+          @keydown.enter="vScrollRef?.scrollToItem(scrollToItemIndex)"
+        />
+        鏉�
+      </a-button>
+    </div>
     <div class="virtual-scroll-demo-wrap">
-      <VScroll :itemHeight="41" :items="data" :height="300" :width="300">
+      <VScroll :itemHeight="41" :items="data" :height="300" :width="300" ref="vScrollRef">
         <template #default="{ item }">
           <div class="virtual-scroll-demo__item">
             {{ item.title }}
@@ -23,12 +41,15 @@
     </div>
   </PageWrapper>
 </template>
-<script lang="ts">
-  import { defineComponent } from 'vue';
-  import { VScroll } from '/@/components/VirtualScroll/index';
+<script lang="ts" setup>
+  import { PageWrapper } from '@/components/Page';
+  import { VScroll } from '@/components/VirtualScroll';
+  import { Divider, InputNumber } from 'ant-design-vue';
+  import { ref } from 'vue';
 
-  import { Divider } from 'ant-design-vue';
-  import { PageWrapper } from '/@/components/Page';
+  const vScrollRef = ref<typeof VScroll>();
+  const scrollToItemIndex = ref(1000);
+
   const data = (() => {
     const arr: any[] = [];
     for (let index = 1; index < 20000; index++) {
@@ -38,12 +59,6 @@
     }
     return arr;
   })();
-  export default defineComponent({
-    components: { VScroll: VScroll, Divider, PageWrapper },
-    setup() {
-      return { data: data };
-    },
-  });
 </script>
 <style lang="less" scoped>
   .virtual-scroll-demo {

--
Gitblit v1.9.3