1.0.1 • Published 5 years ago

vs-pagination v1.0.1

Weekly downloads
33
License
MIT
Repository
github
Last release
5 years ago

vs-pagination

npm.io npm.io npm.io npm.io

vs-pagination, a simple paginator component for Vue. Compared with other popular paginator, vs-pagination doesn't require total page or count, which leads counting-like queries on backend for each paged request. Although there're few approaches to avoid such redundant query against to database, in most CRUD kinda applications, users don't care about how many pages or records in a given list view, they just go-to-next and so forth till there's no data shown.

npm.io

Installation

npm install vs-pagination -S
# or with yarn
yarn add vs-pagination

Usage

Local import

Import component at view page.

import VsPagination from 'vs-pagination'

export default {
  components: {
    VsPagination
  }
}

Global import

import component at main.js.

import VsPagination from 'vs-pagination'
Vue.use(VsPagination)

In template.

<vs-pagination
  :page-no="pageNo"
  :page-size="pageSize"
  :current-page-length="list.length"
  @current-change="onPageChanged"
/>

Set pagination data

export default {
  data() {
    return {
      pageNo: 1,
      pageSize: 20,
      list: []
    }
  }
}

API

Attributes

AttributeEffectTypeRequireDefault
page-nopage numberNumberYes-
page-sizepage sizeNumberYes-
current-page-lengthcurrent page list lengthNumberYes-
sizepaginator sizeStringNosmall (accepted values: small / large)
colorpaginator colorStringNo#1890ff (blue)

Methods

MethodEffectParameters
current-changetriggers when page number changedFunction(currentPage) {}

Example

Full code.

<script>
  import VsPagination from 'vs-pagination'

  export default {
    name: 'App',
    components: {
      VsPagination
    },
    data() {
      return {
        pageNo: 1,
        pageSize: 20,
        list: []
      }
    },
    methods: {
      async fetchList() {},
      onPageChanged(currentPage) {
        this.pageNo = currentPage
        this.fetchList()
      }
    }
  }
</script>
1.0.1

5 years ago

1.0.0

5 years ago

0.2.2

5 years ago

0.2.1

5 years ago

0.2.0

5 years ago

0.1.3

5 years ago

0.1.2

5 years ago

0.1.1

5 years ago

0.1.0

5 years ago

0.0.1

5 years ago

0.0.0

5 years ago