0.0.5 • Published 5 years ago

vue-laravel-the-pagination v0.0.5

Weekly downloads
22
License
-
Repository
-
Last release
5 years ago

[Version] [Downloads]

Laravel VueJs ThePagination

A Vue.js pagination simple component for Laravel paginators.

Requirements

Simple example

Simple example

Install

npm install vue-laravel-the-pagination

Usage

Register the component:

import Vue from 'vue'
import ThePagination from 'vue-laravel-the-pagination';

Vue.use(ThePagination, { // Default config (optional)
    nameComponent: 'ThePagination', // Change name component default: (ThePagination or the-pagination)
    baseURL: 'http://127.0.0.1:8000/api', // Base URL to request
    config: {
        headers: { 
            'Authorization': 'Bearer ...',
            'Accept': 'application/json'
        }
    }
})

Use the component:

<the-pagination 
    url="paginate"
    :query="query" 
    :config="paginateConfig"
    @loading="res => loader = res"
    @getData="res => list = res"
/>
export default {
    data: () => ({
        loader: false,
        list: [],
        query: {
            per_page: 5,
            termToSearch: '',
            status: 0,
            // ADD HERE ALL PARAMS TO GET REQUEST
            // QUERY IS WATCHED, WHEN CHANGE, WILL MAKE NEW REQUEST
        },
        paginateConfig: {
            headers: { 
                'OVERWRITE': 'THIS OVERWRITE DEFAULT CONFIG',
            }
        }
    })
}

Customizing Prev/Next Buttons

Prev/Next buttons can be customized using the first-page, prev-page, next-page and last-page slots:

<the-pagination>
    <span slot="first-page || prev-page || next-page || last-page"> Label </span>
<the-pagination>

Example in Laravel

Backend like this

API

Props

NameTypeDescription
urlString(required) Endpoint for make request
queryObject(optinal) Watched Object to be params request
intervalMaxNumbersNumber(default: 5) Qty numbers to show in pagination (can be unpaired)
configObjectObject to config component

Events

NameReturnDescription
loadingBooleanReturn status request
getDataArrayReturn data with list request
0.0.5

5 years ago

0.0.4

5 years ago

0.0.3

5 years ago

0.0.2

5 years ago

0.0.1

5 years ago