I have code like this :
Im stuck trying to create a pager with vuejs, so I was wonder if anyone can appoint an example of how to make a pager like this if is possible "1-2-3-4-5 ... 55" ??, thanks again for any help.
Check out this code:
https://jsfiddle.net/os7hp1cy/48/
html:
<ul>
<li v-for="pageNumber in totalPages"
v-if="Math.abs(pageNumber - currentPage) < 3 || pageNumber == totalPages - 1 || pageNumber == 0">
<a href="#" @click="setPage(pageNumber)"
:class="{current: currentPage === pageNumber, last: (pageNumber == totalPages - 1 && Math.abs(pageNumber - currentPage) > 3), first:(pageNumber == 0 && Math.abs(pageNumber - currentPage) > 3)}">
{{ pageNumber+1 }}</a>
</li>
</ul>
css:
a.first::after {
content:'...'
}
a.last::before {
content:'...'
}
Basically, it only shows pagination that is within 2 pages of the current page. Then it will also show page 1 and the last page, and will put "..."
before or after the number with CSS. So if you are on page 10, it will show:
1... 8 9 10 11 12 ...21