Last active
September 30, 2019 08:20
-
-
Save smolinari/b908cdbda8532ca2fd3eb0978f290256 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<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