Socket
Book a DemoInstallSign in
Socket

vuejs-pagination

Package Overview
Dependencies
Maintainers
1
Versions
11
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

vuejs-pagination

vue带缓存功能的分页器

latest
npmnpm
Version
1.1.2
Version published
Maintainers
1
Created
Source

Vue Pagination

vue分页组件, 同时支持数据缓存

Vue.js (基于 2.1.0)

demo

安装

npm install vuejs-pagination --save-dev

基本用法

<body id="app">
    <pagination
        :page-num="pageNum"            //总页码必须
        :current-page="activePage"    //当前页必须
        @change="val=>currentPage = val">        //触发事件, 必须
    </pagination>
</body>
import Pagination from 'vuejs-pagination'
new Vue({
    el: '#app',
    data:function() {
        return{
            pageNum : 1, //总页数, 默认1
            activePage : 1 //当前页, 默认1
        }
    }
})

高级用法

缓存功能

<pagination
    :types="types"                 //该接口类型
    :cache-list="list"             //需要缓存的内容
    :page-num="pageNum"            //总页码
    :current-page="activePage"     //当前页
    v-on:change="change">        //页码变化触发事件
</pagination>
//翻页后请求接口前, 先获取缓存数据, 如果没有, 再调用接口
methods: {
    change : function(){
        this.$nextTick(() => {
            const cache = this.$refs.page.getCache();
            if (cache) {
                this.list = cache;
                return;
            }
            $.ajax({
                url : 'xxx'
            })
        }
    }
}

Options

NameDefaultRequiredDescription
page-num1true总页码
current-page1true当前页
page-size5false显示几个页码,需大于3
go-btntruefalse是否展示跳页按钮
cache-listfalse需要缓存的数据
typesfalse需要缓存数据的类型

Emit

NameParamsRequiredDescription
changeval(点击的哪页)true当点击其他页时,会触发该方法

FAQs

Package last updated on 30 Jun 2017

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts