I am trying to work with virtual list in vue. I am first getting some data async then using replaceAllItems to update the virtual list.
The data is displaying in the virtual list but on scroll the area below is just a white empty space. I am loading 1000 items but only about 50 get rendered. I am not sure why it is not updating. Please can someone help me out to understand why it doesn’t work as expected?
<f7-page name="home">
<!-- Top Navbar -->
<f7-navbar :sliding="false" title="Directory">
<a href="#" slot="left">Refresh</a>
<a href="#" slot="right">Log out</a>
<f7-subnavbar :inner="false">
<f7-searchbar
search-container=".virtual-list"
search-item="li"
search-in=".item-title"
:disable-button="!$theme.aurora"
></f7-searchbar>
</f7-subnavbar>
</f7-navbar>
<!-- Page content-->
<f7-list class="searchbar-not-found">
<f7-list-item title="Nothing found"></f7-list-item>
</f7-list>
<f7-list
class="searchbar-found"
media-list
virtual-list
:virtual-list-params="{ items, searchAll, renderExternal, height: $theme.ios ? 63 : ($theme.md ? 73 : 46)}"
>
<ul>
<f7-list-item
v-for="(item, index) in vlData.items"
:key="index"
link="#"
:title="item.name"
:subtitle="item.surname"
></f7-list-item>
</ul>
</f7-list>
</f7-page>
<script>
export default {
data() {
return {
items: [],
vlData: {
items: [],
},
};
},
async beforeCreate() {
// Get some data
let directory = await this.getSomeData()
// Add data to virtual list
var theList = this.$f7.virtualList.get();
theList.replaceAllItems(directory);
},
methods: {
searchAll(query, items) {
const found = [];
for (let i = 0; i < items.length; i += 1) {
if (items[i].name.toLowerCase().indexOf(query.toLowerCase()) >= 0 || query.trim() === '') found.push(i);
}
return found; // return array with matched indexes
},
renderExternal(vl, vlData) {
this.vlData = vlData;
},
},
};
</script>