|
|
@ -1,8 +1,26 @@ |
|
|
<template> |
|
|
<template> |
|
|
<PageWrapper class="virtual-scroll-demo"> |
|
|
<PageWrapper class="virtual-scroll-demo"> |
|
|
<Divider>基础滚动示例</Divider> |
|
|
<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"> |
|
|
<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 }"> |
|
|
<template #default="{ item }"> |
|
|
<div class="virtual-scroll-demo__item"> |
|
|
<div class="virtual-scroll-demo__item"> |
|
|
{{ item.title }} |
|
|
{{ item.title }} |
|
|
@ -24,9 +42,13 @@ |
|
|
</PageWrapper> |
|
|
</PageWrapper> |
|
|
</template> |
|
|
</template> |
|
|
<script lang="ts" setup> |
|
|
<script lang="ts" setup> |
|
|
import { VScroll } from '@/components/VirtualScroll'; |
|
|
|
|
|
import { Divider } from 'ant-design-vue'; |
|
|
|
|
|
import { PageWrapper } from '@/components/Page'; |
|
|
import { PageWrapper } from '@/components/Page'; |
|
|
|
|
|
import { VScroll } from '@/components/VirtualScroll'; |
|
|
|
|
|
import { Divider, InputNumber } from 'ant-design-vue'; |
|
|
|
|
|
import { ref } from 'vue'; |
|
|
|
|
|
|
|
|
|
|
|
const vScrollRef = ref<typeof VScroll>(); |
|
|
|
|
|
const scrollToItemIndex = ref(1000); |
|
|
|
|
|
|
|
|
const data = (() => { |
|
|
const data = (() => { |
|
|
const arr: any[] = []; |
|
|
const arr: any[] = []; |
|
|
|