Giter Club home page Giter Club logo

vue-simple-pager's Introduction

vue-simple-pager

an all-round pagination component based on vue

Test

clone this repo
cd vue-simple-pager
npm install .
npm run test
open your browser and request http://localhost:8080/test/test.html

/images/vue-simple-pager.gif

Usage

npm install vue-simple-pager

for simple usage, you only need transfer props as follow:

props: {
    totalPage: { // total 
        type: Number,
        default: 1,
        required: true
    },
    showItems: { // such as 1 ... 34[5]67 ... 10
        type: Number,
        default: 5
    },
    showPrev: { // whether to show 'Prev'
        type: Boolean,
        default: true
    },
    showNext: { // whether to show 'Next'
        type: Boolean,
        default: true
    },
    showJump: { // whether to show 'Go'
        type: Boolean,
        default: true
    },
    initPage: { // initial page
        type: Number,
        default: 1
    }

when page changed, it will emit an event named 'go-page', so in your template:

<div id="app">
    <pager
        :total-page="totalPage"
        :init-page="page"
        @go-page="goPage"></pager>
    <p>page: {{page}}</p>
</div>

in your js:

import pager from 'vue-simple-pager'

new Vue({
    el: '#app',
    data () {
        return {
            page: 1,
            totalPage: 10
        }
    },
    methods: {
        goPage (data) {
            this.page = data.page
        }
    },
    components: {
        'pager': pager
    }
})

for more usage:

When using vue-router, usually there is a need that different page can be put in history so that we can navigate them by using browser [go,back] buttons. Now you only need to add two props:

{
    mode: { // 3 modes are supported : 'event' | 'query' | 'params'
        type: String,
        default: 'event'
    },
    routeName: { // if mode == 'params', a routeName is required
        type: String
    }
}

For more usage detail, see the test example

License

MIT

vue-simple-pager's People

Contributors

hyiso avatar

Watchers

James Cloos avatar vincent-cong avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.