Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/mrosendin/vue-bulma-pagination

Vue.js 2 Bulma pagination component
https://github.com/mrosendin/vue-bulma-pagination

bulma pagination vue

Last synced: about 1 month ago
JSON representation

Vue.js 2 Bulma pagination component

Awesome Lists containing this project

README

        

# Vue Bulma Pagination

[![npm version](https://badge.fury.io/js/vue-2-bulma-pagination.svg)](https://badge.fury.io/js/vue-2-bulma-pagination)

> A Vue.js pagination component for the Bulma CSS framework

View the [demo](https://rosendin.github.io/vue-bulma-pagination/).

## Installation

Install via NPM:

``` bash
npm install vue-2-bulma-pagination --save
```

## Usage

**Props**

|Name|Type|Required|Default|Description|
|----|----|--------|-------|-----------|
|current|Number|True|N/A|Current page|
|total|Number|False|0|Total number of items|
|itemsPerPage|Number|True|N/A|Items per page|
|step|Number|False|3|Number of pages to display (besides first and last)|
|onChange|Function|True|N/A|Page changed event callback. Parameters: page|

**Example**

Use like below. See the [example code](https://github.com/roseware/vue-bulma-pagination/blob/master/src/Demo.vue) in the demo.

``` html




{{ key }}




{{ country[key] }}



import Pagination from 'vue-2-bulma-pagination'
import axios from 'axios';

let pagination = {
current: 1, // Current page
total: 0, // Items total count
itemsPerPage: 5 // Items per page
}

export default {
name: 'demo',
components: { Pagination },
data () {
return {
countries: [],
pagination: pagination
}
},
methods: {
onChange (page) {
console.log(`Getting page ${page}`)
axios.get(`https://api.openaq.org/v1/countries?limit=5&page=${page}`)
.then(response => {
this.countries = response.data.results
this.pagination.current = page
})
}
},
created () {
axios.get('https://api.openaq.org/v1/countries?limit=5')
.then(response => {
this.keys = Object.keys(response.data.results[0])
this.countries = response.data.results

// Set pagination config based on response
this.pagination.total = response.data.meta.found
})
}
}

```

## Development

``` bash
# install dependencies
npm install

# serve with hot reload at localhost:8080
npm run dev
```

For detailed explanation on how things work, consult the [docs for vue-loader](http://vuejs.github.io/vue-loader).