Skip to content

Instantly share code, notes, and snippets.

@smolinari
Last active September 30, 2019 08:20
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save smolinari/b908cdbda8532ca2fd3eb0978f290256 to your computer and use it in GitHub Desktop.
Save smolinari/b908cdbda8532ca2fd3eb0978f290256 to your computer and use it in GitHub Desktop.
<template>
<q-virtual-scroll
style="max-height: 300px; overflow-x: hidden"
:items-size="size"
:items-fn="getItems"
:virtual-scroll-item-size="78"
separator
>
<template v-slot="{ item, index }">
<some-component :key="index" :index="item.index" :sent="item.sent" />
</template>
</q-virtual-scroll>
</template>
<script>
export default {
data () {
return {
size: 100000
}
},
methods: {
getItems (from, size) {
const items = []
for (let i = 0; i < size; i++) {
items.push({
index: this.size - from - i,
sent: Math.random() > 0.5
})
}
// Object.freeze() is optional but good for
// performance you don't intend to change anything
// in items later:
return Object.freeze(items)
}
}
}
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment