1.0.1 • Published 3 years ago

vue-cli-laravel-pagination v1.0.1

Weekly downloads
-
License
ISC
Repository
github
Last release
3 years ago

Vue Cli Laravel Pagination

vue-cli-laravel-pagination is a plugin for implementing laravel pagination in on a vue cli based project. it's light weight, easy to use, well documented and has best support.

Preview

npm.io

Requirements

Install

npm install vue-cli-laravel-pagination

Usage

In your main.js:

import VueLaravelPagination from "vue-cli-laravel-pagination";


Vue.use(VueLaravelPagination)

Use the component:

<vue-cli-laravel-pagination :data="laravelData" align="center" :onChange="changed_value" buttonLimit="10"></vue-cli-laravel-pagination>
export default {

	data() {
		return {
			laravelData: {},
		}
	},
	mounted() {
		this.fetch();
	},
	methods: {
        // Detect page change event
        changed_value(options){
            console.log(options.page)
            this.fetch(options.page)
        },

		// Fetch data from a Laravel endpoint
	fetch(page = 1) {
		axios.get('example.com/fetch-url-here?page=' + page)
			.then(response => {
			    this.laravelData = response.data;
			});
	    }
	}

}

API

NameTypeDescription
dataObjectAn object containing the structure of a Laravel paginator response or a Laravel API Resource response.
alignString(optional) One of left (default), center or right
onChangeFunctionCallback event to detect button click and get selected page count
buttonLimitNumber(optional) Numbers of pages to show default 5
prevBtnString/HTML(optional) Customize previous button
nextBtnString/HTML(optional) Customize Next button

Show your Support

To show your support for my work on this project:

Credits

Vue Cli Laravel Pagination was created by Ahmed Zobayer. Released under the ISC license.