-
Notifications
You must be signed in to change notification settings - Fork 11
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
How to apply the pagination #18
Comments
Did you see the Demo in Plunkr? Take a look at script.js. |
I did, but I can't see anywhere any v-for to iterate through my items or how to apply pagination to my existing array. |
Well, that implementation needs to be done by your side. This is just a plugin that shows a pagination banner below your data. However you can follow this script that may help you in what you need: export function paginateItems(items, currentPage, itemsPerPage) {
const start = currentPage * itemsPerPage - itemsPerPage;
const end = currentPage * itemsPerPage;
return items.slice(start, end);
}
const data = [
1,2,3,
4,5,6,
7,8,9,
];
// Suppose you are going to show 2 items per page and you are in the 3rd page.
const pageData = paginateItems(data, 3, 2);
console.log(pageData); // [ 5, 6 ] That |
It helps. thanks! |
I'm not sure how to implement this on my app. Let's say I have an array of items called
Items
how would I implement this plugin to work on my Items array?The text was updated successfully, but these errors were encountered: