虚拟滚动
仅渲染可视区域与缓冲范围内的卡片,轻松应对长列表。
Vue WF 聚焦于媒体密集场景的性能与可用性。通过简单的属性驱动 API 与虚拟化渲染,你可以在滚动数百甚至上千张图片时保持顺滑交互。
<script setup lang="ts">
import Waterfall from 'vue-wf'
const tmps = Array.from({ length: 100 })
const heights = [50, 100, 200, 300, 400]
const width = 100
const items = tmps.map(() => {
const height = heights[Math.floor(Math.random() * heights.length)]
return {
width,
height,
src: `https://picsum.photos/${width}/${height}?random=${Math.random()}`,
}
})
</script>
<template>
<Waterfall
:wrapper-width="400"
:item-width="width"
:gap="20"
>
<div
v-for="item, i in items"
:key="i"
:style="{
height: `${item.height / item.width * 100}px`,
backgroundImage: `url(${item.src})`,
}"
/>
</Waterfall>
</template>pnpm docs:dev 与 pnpm docs:build