primevue-mirror/apps/showcase/doc/select/VirtualScrollDoc.vue

64 lines
2.2 KiB
Vue
Raw Normal View History

2023-02-28 08:29:30 +00:00
<template>
<DocSectionText v-bind="$attrs">
<p>
VirtualScroller is used to render a long list of options efficiently like 100K records in this demo. The configuration is done with <i>virtualScrollerOptions</i> property, refer to the
2024-04-18 14:22:30 +00:00
<NuxtLink to="/virtualscroller">VirtualScroller</NuxtLink> for more information about the available options as it is used internally by Select.
2023-02-28 08:29:30 +00:00
</p>
</DocSectionText>
2024-05-20 12:14:38 +00:00
<div class="card flex justify-center">
<Select v-model="selectedItem" :options="items" optionLabel="label" optionValue="value" :virtualScrollerOptions="{ itemSize: 38 }" placeholder="Select Item" class="w-full md:w-56" />
2023-02-28 08:29:30 +00:00
</div>
<DocSectionCode :code="code" />
</template>
<script>
export default {
data() {
return {
selectedItem: null,
items: Array.from({ length: 100000 }, (_, i) => ({ label: `Item #${i}`, value: i })),
code: {
2023-09-22 12:54:14 +00:00
basic: `
2024-04-18 14:22:30 +00:00
<Select v-model="selectedItem" :options="items" optionLabel="label" optionValue="value"
2024-05-20 12:14:38 +00:00
:virtualScrollerOptions="{ itemSize: 38 }" placeholder="Select Item" class="w-full md:w-56" />
2023-10-15 09:38:39 +00:00
`,
2023-09-22 12:54:14 +00:00
options: `
<template>
2024-05-20 12:14:38 +00:00
<div class="card flex justify-center">
2024-04-18 14:22:30 +00:00
<Select v-model="selectedItem" :options="items" optionLabel="label" optionValue="value"
2024-05-20 12:14:38 +00:00
:virtualScrollerOptions="{ itemSize: 38 }" placeholder="Select Item" class="w-full md:w-56" />
2023-02-28 08:29:30 +00:00
</div>
</template>
<script>
export default {
data() {
return {
selectedItem: null,
items: Array.from({ length: 100000 }, (_, i) => ({ label: \`Item #\${i}\`, value: i }))
};
}
};
2023-10-15 09:38:39 +00:00
<\/script>
`,
2023-09-22 12:54:14 +00:00
composition: `
<template>
2024-05-20 12:14:38 +00:00
<div class="card flex justify-center">
2024-04-18 14:22:30 +00:00
<Select v-model="selectedItem" :options="items" optionLabel="label" optionValue="value"
2024-05-20 12:14:38 +00:00
:virtualScrollerOptions="{ itemSize: 38 }" placeholder="Select Item" class="w-full md:w-56" />
2023-02-28 08:29:30 +00:00
</div>
</template>
<script setup>
import { ref } from "vue";
const selectedItem = ref();
const items = ref(Array.from({ length: 100000 }, (_, i) => ({ label: \`Item #\${i}\`, value: i })));
2023-10-15 09:38:39 +00:00
<\/script>
`
2023-02-28 08:29:30 +00:00
}
};
}
};
</script>