vue-pagenav
a vue pagenav plugin.
(since v2.0.0 support vue 2 only, use 1.x for vue1+)
check the demo
http://html5beta.com/apps/vue-pagenav.html
get
bower install vue-pagenav #for 1.0+ users, bower install vue-pagenav#1 #or npm install vue-pagenav #for 1.0+ users, npm install vue-pagenav@1
use
reference it in html
new way to change page, supported by vue 1.0+/2.0+
el: '#test' data: page: 1 //page pageSize: 10 //pageSize, default is 10 total: 509 //total item count maxLink: 5 //how many links to show, must not less than 5, default is 5 methods: { //here you can do custom state update thispage = page } { return unitpage > 1?'#page=' + unitpage:'#' }
the vue 1.x way by event, for vue 1.x
//commonjs wayvar Vue = var zPagenav = Vue //or direct use if window.Vue exists//Vue.use(window.zPagenav) el: '#test' data: page: 1 //page pageSize: 10 //pageSize, default is 10 total: 509 //total item count maxLink: 5 //how many links to show, must not less than 5, default is 5 // page change event name, default is 'page-change', // optional // for different pagenav, should use different name eventName: 'custom' events: { thispage = page console }
style it, just the same css from bootstrap4 pagination module
customize
var zPagenav = default: page: 1 //page pageSize: 10 //pageSize total: 0 //total items count prevHtml: '«' //prev button html nextHtml: '»' //next button html prevSrHtml: 'Previous' //prev button screen reader html nextSrHtml: 'Next' //next button screen reader html dotsHtml: '...' //sepration element html template: //template `<nav class="zpagenav">` + `<span class="pagination page-link m-r-1">total:{{total}}</span>` + `<ul class="pagination">` + `<li track-by="$index" v-for="unit in units" :class="'page-item ' + unit.class" :disabled="unit.disabled">` + `<a @click.prevent="setPage(unit.page)" class="page-link" :href="setUrl(unit)" :aria-label="unit.ariaLabel">` + `<span v-if="unit.isPager" aria-hidden="true" v-html="unit.html"></span>` + `<span v-else v-html="unit.html"></span>` + `<span v-if="unit.isPager" class="sr-only" v-html="unit.srHtml"></span>` + `</a>` + `</li>` + `</ul>` + `</nav>` //by modify zPagenav.default to customize the template or other params, like:zPagenavdefaultnextHtml = 'next'
test & build & dev
git clone https://github.com/zxdong262/vue-pagenav.gitcd vue-pagenavnpm installnpm run test #build npm run build #dev npm start
License
MIT