2.0.0 • Published 3 years ago

v-simple-paginate v2.0.0

Weekly downloads
17
License
MIT
Repository
github
Last release
3 years ago

v-simple-paginate

NPM

npm version Build Status

Vue.js (v2.x +) component for make pagination without default styles. This allows you to style the component as you wish.

Demo

Installation

NPM

$ npm i v-simple-paginate

YARN

$ yarn add v-simple-paginate

CDN

<!-- use the latest release -->
<script src="https://unpkg.com/v-simple-paginate@latest"></script>
<!-- or use the specify version -->
<script src="https://unpkg.com/v-simple-paginate@2.0.0"></script>

Register the component

Global

  • ES5
var Vue = require('vue');
var Paginate = require('v-simple-paginate');
Vue.component('paginate', Paginate);
  • ES6+
import Vue from 'vue';
import Paginate from 'v-simple-paginate';
Vue.component('paginate', Paginate);

Local

import Paginate from 'v-simple-paginate';

export default {
    components: { Paginate }
}

Usage

Basic Usage

<paginate
  :value="currentPage"
  :per-page="perPage"
  :total="total"
  @input="callback()"
/>

Note: In vue template, camelCase and kebab-case are both supported. For example, you can either use prop page-count or pageCount. They are leading to the same result.

So this is also available

<paginate
  v-model="currentPage"
  :perPage="perPage"
  :total="total"
/>

Example

<template>
  <paginate
    :value="currentPage"
    :per-page="perPage"
    :total="total"
    @input="callback"
  />
</template>

<script>
export default {
  data: () => ({
    total: 500,
    perPage: 10,
    currentPage: 1,
  }),

  methods: {
    callback (pageNumber) => {
      console.log(pageNumber);
      ...
      this.currentPage = pageNumber;
    }
  }
}
</script>

<style lang="css">
.active {
    background-color: red;
}

.hide {
    display: none;
}
</style>

Props

Name                                       TypeRequiredDescription
valueNumbertrueCurrent page.
perPageNumbertrueNumber of items per page.
totalNumbertrueTotal items.
pageRangeNumberfalseThe range of visible elements around the active page. Default: 2
showPrevNextBooleanfalseWill the previous and next buttons be visible. Default: true
activeClassStringfalseCSS class name for active page element. Default: 'active'
btnHideClassStringfalseCSS class name for active page element. Default: 'active'
classesObjectfalseAn object with CSS classes to customization the component.
About props classes
Name                          Description
wrapperClassCSS class name for wrapper the component.
itemClassCSS class name for all items (buttons and break view).
btnClassCSS class name for buttons class.
breakViewClassCSS class name for break view.
prevNextClassCSS class name for previous and next buttons.

Default:

{
  wrapperClass: 'v-simple-pagination',
  itemClass: '',
  btnClass: '',
  breakViewClass: '',
  prevNextClass: '',
}

Slots

Name                                     Description
prevContentPrevious button
nextContentNext button
breakViewContentBreak view indicator

Example

<paginate
  :value="currentPage"
  :perPage="perPage"
  :total="total"
  @input="callback"
>
  <template v-slot:prevPage>PREV</template>

  <template v-slot:nextPage>NEXT</template>

  <template v-slot:breakView>...</template>
</paginate>

Emit

Emit: input is a callback with the param page number to update the current page.

License

MIT

2.0.0

3 years ago

1.0.0

4 years ago

1.0.5

4 years ago

0.1.6

4 years ago

0.1.5

4 years ago

0.1.2

4 years ago

0.1.1

4 years ago

0.1.4

4 years ago

0.1.3

4 years ago

0.1.0

4 years ago