Skip to content

HuangdaoyuChen/vue-pagination

 
 

Repository files navigation

vue-pagination

Modified Vue pagination component for Vue.js 1.x based on vue-pagination. I added links to first and last pages of pagination and also changed icons for personal use. Installation information below is for original vue-pagination.

Screenshots

Original

image

Modified(Now)

image

Original README.md

Vue pagination component for use with Bootstrap and Laravel pagination.

Laravel is not required as long as the pagination object contains the required attributes

  • current_page,
  • last_page,
  • per_page,
  • to

Installation

NPM

$ npm install vue-bootstrap-pagination

Bower

$ bower install vue-bootstrap-pagination

Example

new Vue({
  el: '#app',
  data: function () {
    return {
      items: [],
      pagination: {
        total: 0, per_page: 12,
        from: 1, to: 0,
        current_page: 1
      }
    }
  },
  methods: {
    loadData: function () {
      var data = {
        paginate: this.pagination.per_page,
        page: this.pagination.current_page,
        /* additional parameters */
      };
      this.$http.get('/getData', data).then(function (response) {
        this.$set('items', response.data.data);
        this.$set('pagination', response.data.pagination);
      }, function(error) {
        // handle error
      });
    }
  },
  components: {
    pagination: require('vue-bootstrap-pagination')
  }
})
<body id="app">
  <ul class="list-group">
    <li class="list-group-item" v-for="item in items">{{ item.name }}</li>
  </ul>

  <pagination :pagination="pagination" :callback="loadData" :offset="3"></pagination>
</body>

Options

Name Type Default Required Description
pagination Object true Pagination object used to create pagination
callback Function true Callback function used to load data for selected page
offset Number 4 Left and right offset of pagination numbers to display

About

Add links to first/last pages for vue-pagination(Vue 1.x)

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • JavaScript 100.0%