Add 'go to' page
This commit is contained in:
parent
a2d64b55c1
commit
bd69b5fc32
1 changed files with 13 additions and 3 deletions
|
@ -74,9 +74,8 @@
|
||||||
<button
|
<button
|
||||||
:class="`col md-btn page-btn${ isCurrentPage(page) ? ' md-btn-primary': ''}`"
|
:class="`col md-btn page-btn${ isCurrentPage(page) ? ' md-btn-primary': ''}`"
|
||||||
@click="goToPage(page)"
|
@click="goToPage(page)"
|
||||||
v-for="page in pagesToShow">
|
v-for="page in pagesToShow"
|
||||||
{{ page }}
|
>{{ page }}</button>
|
||||||
</button>
|
|
||||||
<button
|
<button
|
||||||
class="col md-btn page-btn next"
|
class="col md-btn page-btn next"
|
||||||
:disabled="currentPage === numPages"
|
:disabled="currentPage === numPages"
|
||||||
|
@ -91,6 +90,10 @@
|
||||||
>
|
>
|
||||||
<img class="md-ico-last"/>
|
<img class="md-ico-last"/>
|
||||||
</button>
|
</button>
|
||||||
|
<div class="col page-btn" style="min-width: 12em;">
|
||||||
|
<input type="number" min="1" :max="numPages" :value="currentPage" @change="changePage" />
|
||||||
|
<span>/ {{ numPages }}</span>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
@ -164,6 +167,13 @@
|
||||||
return idx === this.currentPage ||
|
return idx === this.currentPage ||
|
||||||
idx === this.numPages && this.currentPage > this.numPages;
|
idx === this.numPages && this.currentPage > this.numPages;
|
||||||
},
|
},
|
||||||
|
changePage: function (event) {
|
||||||
|
const value = event.target.valueAsNumber;
|
||||||
|
|
||||||
|
if (!isNaN(value) && value >= 1 && value <= this.numPages) {
|
||||||
|
this.currentPage = value;
|
||||||
|
}
|
||||||
|
},
|
||||||
goToPage: function (page) {
|
goToPage: function (page) {
|
||||||
this.currentPage = page;
|
this.currentPage = page;
|
||||||
},
|
},
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue