-
Notifications
You must be signed in to change notification settings - Fork 0
/
pagination.js
29 lines (23 loc) · 992 Bytes
/
pagination.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
Vue.component('pagination',{
template: `<nav aria-label="Page navigation example">
<ul class="pagination">
<li class="page-item">
<a class="page-link" :class="{'disabled': pages.current_page === 1}" href="#" aria-label="Previous" @click.prevent="updatePages(pages.current_page-1)">
<span aria-hidden="true">«</span>
</a>
</li>
<li class="page-item" :class="{'active': item == pages.current_page}" v-for="(item,key) in pages.total_pages" :key="key"><a class="page-link" href="#" @click.prevent="updatePages(item)">{{item}}</a></li>
<li class="page-item">
<a class="page-link" :class="{'disabled': pages.current_page === pages.total_pages}" href="#" aria-label="Next" @click.prevent="updatePages(pages.current_page+1)">
<span aria-hidden="true">»</span>
</a>
</li>
</ul>
</nav>`,
props: ['pages'],
methods: {
updatePages(num) {
this.$emit('update',num);
}
}
});