Home

Awesome

Vue Pagination 2

Using Vue 3? Check out the new component


Click here to see it in action.

Simple, generic and non-intrusive pagination component for Vue.js version 2.

Dependencies

Installation

NPM

npm install vue-pagination-2

import the script:

import Pagination from 'vue-pagination-2';

Script tag

Grab the minified version under dist/vue-pagination-2.min.js. It will export a global Pagination variable.

Usage

Register the component globally or locally:

Vue.component('pagination', Pagination);

OR

...
components: {
  Pagination
}
...

HTML/JS:

{
    data() {
       return {
           page: 1
       }    
    }
}
<pagination v-model="page" :records="500" @paginate="myCallback"/>

props:

Custom Event

The model you bound to the component will be automatically updated. In addition, when a page is selected a custom paginate event will be dispatched. Listen to it on the component and run your callback

Programmatic Manipulation

The simplest way to programmatically manipulate the page is to directly update your bound model.

In addition to that you can call the following methods using a ref on you component:

All methods return true if the page is legal and was thus set, or false otherwise.

Computed Properties

Custom Template

You can easily build your own template by copying src/Pagination.vue to your project as a starting point and modifying the contents to your needs. Then notify the component of your custom template by passing it to the template option.

import MyPagination from './MyPagination'
...
{
    options: {
        template: MyPagination    
    }   
}