项目作者: vinayakkulkarni

项目描述 :
A VueJS 2.x pagination used with Laravel & Semantic-UI :sunny:
高级语言: JavaScript
项目地址: git://github.com/vinayakkulkarni/laravel-vue-semantic-ui-pagination.git
创建时间: 2017-08-28T12:27:31Z
项目社区:https://github.com/vinayakkulkarni/laravel-vue-semantic-ui-pagination

开源协议:MIT License

下载


Build Status

Laravel Vue Semantic-UI Pagination :zap:

  • A Vue.js pagination component for Laravel paginators that works with Semantic-UI.

  • This is on GitHub so let me know if I’ve b0rked it somewhere, give me a star :star: if you like it :beers:

  • You can checkout the Demo

Requirements

:white_check_mark: Install :ok_hand:

  1. npm install laravel-vue-semantic-ui-pagination
  2. // or
  3. yarn add laravel-vue-semantic-ui-pagination

:white_check_mark: Usage :mortar_board:

Register the component globally:

  1. Vue.component('pagination', require('laravel-vue-semantic-ui-pagination'));

Or use locally

  1. import pagination from 'laravel-vue-semantic-ui-pagination';

:white_check_mark: Example :four_leaf_clover:

  1. <ul>
  2. <li v-for="post in laravelData.data" v-text="post.title"></li>
  3. </ul>
  4. <pagination :data="laravelData" v-bind:showDisabled="true" icon="chevron" v-on:change-page="getResults"></pagination>
  1. Vue.component('example-component', {
  2. data() {
  3. return {
  4. // Our data object that holds the Laravel paginator data
  5. laravelData: {},
  6. }
  7. },
  8. created() {
  9. // Fetch initial results
  10. this.getResults();
  11. },
  12. methods: {
  13. // Our method to GET results from a Laravel endpoint
  14. getResults(page) {
  15. if (typeof page === 'undefined') {
  16. page = 1;
  17. }
  18. // Using vue-resource as an example
  19. this.$http.get('example/results?page=' + page)
  20. .then(response => {
  21. return response.json();
  22. }).then(data => {
  23. this.laravelData = data;
  24. });
  25. }
  26. }
  27. });

:white_check_mark: :book: Props

Name Type Description
data Object An object containing the structure of a Laravel paginator response. See below for default value.
limit Number (optional) Limit of pages to be rendered. Default 0 (unlimited links) -1 will hide numeric pages and leave only arrow navigation. 3 will show 3 previous and 3 next numeric pages from current page.
showDisabled Boolean (optional) If set to true, will display left and right icons always.
icon String (optional) Default is angle double; Refer Semantic-UI Icons for specifying which icons you want.
size String (optional) Default is small; Refer Semantic-UI Menu Pagination for specifying the size of paginator.
  1. {
  2. current_page: 1,
  3. data: [],
  4. from: 1,
  5. last_page: 1,
  6. next_page_url: null,
  7. per_page: 10,
  8. prev_page_url: null,
  9. to: 1,
  10. total: 0,
  11. }

:white_check_mark: :ear: Events

Name Description
change-page Triggered when a user changes page. Passes the new page index as a parameter.

NPM :octocat:

NPM