Infinity loading component vue3 projects. Slava Ukraini!
npm install @ts-pro/vue-eternal-loadingThe Infinity loading component is written in TypeScript for Vue 3. No dependencies.
yarn add @ts-pro/vue-eternal-loading
`Npm
`
npm install @ts-pro/vue-eternal-loading
`Browser
`html
`$3
`html
`
`ts
const PAGE_SIZE = 5;// We need to pass this method to the component,
// and it will be called automatically when needed.
async function load({ loaded }) {
// Load your data from the server or any other source.
const loadedItems = await loadItems(page);
items.value.push(...loadedItems);
page += 1;
// Call the
loaded callback with 2 arguments:
// 1. The number of items we have loaded
// 2. Our page size to know when we have reached the end
loaded(loadedItems.length, PAGE_SIZE);
}
``