1.0.0 • Published 8 years ago

vue2-pagination v1.0.0

Weekly downloads
4
License
ISC
Repository
github
Last release
8 years ago

vue-pagination

中文文档

Pagination component for Vue.js.

Compatibility Note : vue-pagination requires Vue.js 1.0.0+

Installation

  • Script Tag

    <script type="text/javascript" src="http://cdn.bootcss.com/vue/1.0.26/vue.js"></script>
    <script type="text/javascript" src="./dist/vue-pagination.min.js"></script>
  • NPM

    I don't publish this repo on npm, you can install by github.

    npm install https://github.com/luoye-fe/vue-pagination.git

Usage

  • template

    <v-pagination :pagination-config.sync="config"></v-pagination>
  • js

    export default {
        data() {
            return {
                config: {
                    currentPage: 1,
                    itemsPerPage: 10,
                    pagesLength: 5,
                    totalItems: 0,
                    onChange() {}
                }
            };
        },
        ready() {
            this.config.onChange = () => {
                console.log(this.config.currentPage);
            };
        }
    };

Demo

Demo

Options

  • use options

    While useing Commonjs/ES6 Module, you should exec Vue.use(VuePagination), at this point you can pass options by Vue.use(VuePagination, optionsObj).

    NameTypeDefaultRequiredDescription
    tagNameStringvue-paginationcustom tag name

    example

    import Vue from 'vue';
    import VuePagination from 'vue-pagination';
    Vue.use(VuePagination, {
        tagName: 'vue-pagintaion'
    })
  • pagination config

    vue-pagination accept props named pagination-config.sync, you must pass some required options, all options as follows.

    NameTypeDefaultRequiredDescription
    firstStrStringFirstfalseFirst button text
    prevStrStringPrevfalsePrev button text
    nextStrStringNextfalseNext button text
    lastStrStringLastfalseLast button text
    firstBooleanTruefalseNeed first button or not
    prevBooleanTruefalseNeed prev button or not
    nextBooleanTruefalseNeed next button or not
    lastBooleanTruefalseNeed last button or not
    normalBooleanTruefalseNeed normal page list or not
    currentPageNumber1falseCurrentPage
    itemsPerPageNumber10falseItem number every page
    pagesLengthNumber5falseNormal page list length
    totalItemsNumber0trueTotal items number (calculate numbers of page by this)
    onChangeFunctionfalseCallback function when currentPage change