Vue Virtual Scroll List (current stable version 2.3.5) is a high-performance Vue 2 component designed to efficiently render large datasets as scrollable lists. It addresses the performance challenges of rendering thousands of items by only rendering the visible subset, significantly improving user experience. Key differentiators include its simple API with only three required props (`data-key`, `data-sources`, `data-component`), automatic item size calculation (eliminating the need for fixed-height items), and efficient rendering. The library appears to be actively maintained, with regular minor updates addressing bug fixes and small enhancements, as evidenced by recent patch releases in the 2.x series.
npm install vue-virtual-scroll-listVerified import paths — ran on the pinned version, not inferred.
This example demonstrates how to set up `vue-virtual-scroll-list` in a Vue component, passing a large dataset and a custom item component. It highlights the essential `data-key`, `data-sources`, and `data-component` props, along with making the container scrollable.
Update your component usage from `:data-model="YourComponent"` to `:data-component="YourComponent"`.
Change `:data-uid="'id'"` to `:data-key="'id'"`.
Ensure your `VirtualList` parent or `VirtualList` itself has `style="height: Xpx; overflow-y: auto;"` (or similar CSS) applied.
Ensure the property specified by `data-key` (e.g., `'uid'`) holds a unique value for every object in your `data-sources` array. If your data doesn't naturally have a unique key, generate one.
Add `height` and `overflow-y: auto` (or `scroll`) CSS properties to the container wrapping `VirtualList` or to the `VirtualList` component itself.
Verify that the property specified by `data-key` (e.g., `'id'` or `'uid'`) is unique for every item in your `data-sources`. If necessary, generate a unique ID for each item.
Ensure your `ItemComponent.vue` is correctly imported (e.g., `import ItemComponent from './ItemComponent.vue'`) and assigned to `data-component`.
Check the structure of your objects in the `data-sources` array and ensure that your `ItemComponent`'s template and script correctly reference existing properties on the `source` prop.