83 lines
1.5 KiB
Vue
83 lines
1.5 KiB
Vue
<script setup lang="ts">
|
|
import {
|
|
ListBox,
|
|
ListBoxItem,
|
|
ListBoxItemIndicator,
|
|
Label,
|
|
Description,
|
|
} from "@heroui-vue/components";
|
|
const firstNames = [
|
|
"Emma",
|
|
"Liam",
|
|
"Olivia",
|
|
"Noah",
|
|
"Ava",
|
|
"James",
|
|
"Sophia",
|
|
"Oliver",
|
|
"Isabella",
|
|
"Lucas",
|
|
"Mia",
|
|
"Ethan",
|
|
"Charlotte",
|
|
"Mason",
|
|
"Amelia",
|
|
"Logan",
|
|
"Harper",
|
|
"Alexander",
|
|
"Ella",
|
|
"Benjamin",
|
|
];
|
|
const lastNames = [
|
|
"Smith",
|
|
"Johnson",
|
|
"Williams",
|
|
"Brown",
|
|
"Jones",
|
|
"Garcia",
|
|
"Miller",
|
|
"Davis",
|
|
"Rodriguez",
|
|
"Martinez",
|
|
"Anderson",
|
|
"Taylor",
|
|
"Thomas",
|
|
"Jackson",
|
|
"White",
|
|
"Harris",
|
|
"Clark",
|
|
"Lewis",
|
|
"Robinson",
|
|
"Walker",
|
|
];
|
|
const users = Array.from({ length: 1000 }, (_, index) => {
|
|
const first = firstNames[index % firstNames.length];
|
|
const last =
|
|
lastNames[Math.floor(index / firstNames.length) % lastNames.length];
|
|
return {
|
|
id: index + 1,
|
|
name: `${first} ${last}`,
|
|
textValue: `${first} ${last}`,
|
|
email: `${first.toLowerCase()}.${last.toLowerCase()}@acme.com`,
|
|
};
|
|
});
|
|
</script>
|
|
<template>
|
|
<ListBox
|
|
:items="users"
|
|
virtualized
|
|
:row-height="50"
|
|
aria-label="包含 1000 项的虚拟化列表"
|
|
class="h-[400px] w-[300px] overflow-y-auto"
|
|
v-slot="{ item }"
|
|
>
|
|
<ListBoxItem :id="item.id" :text-value="item.name" class="h-full">
|
|
<div class="flex flex-col">
|
|
<Label>{{ item.name }}</Label>
|
|
<Description>{{ item.email }}</Description>
|
|
</div>
|
|
<ListBoxItemIndicator />
|
|
</ListBoxItem>
|
|
</ListBox>
|
|
</template>
|