mrshanebarron/pagination
Composer 安装命令:
composer require mrshanebarron/pagination
包简介
Pagination component for Laravel - supports Livewire and Vue
README 文档
README
A pagination component for Laravel applications. Displays page numbers with navigation controls. Works with Livewire and Vue 3.
Installation
composer require mrshanebarron/pagination
Livewire Usage
Basic Usage
<livewire:sb-pagination wire:model="page" :total-pages="10" />
With Item Count
<livewire:sb-pagination wire:model="page" :total-pages="15" :per-page="20" :total="300" :show-info="true" />
Livewire Props
| Prop | Type | Default | Description |
|---|---|---|---|
wire:model |
number | 1 |
Current page number |
total-pages |
number | required | Total number of pages |
per-page |
number | 10 |
Items per page |
total |
number | 0 |
Total item count |
on-each-side |
number | 2 |
Pages shown on each side |
show-info |
boolean | true |
Show "Showing X to Y of Z" |
Vue 3 Usage
Setup
import { SbPagination } from './vendor/sb-pagination'; app.component('SbPagination', SbPagination);
Basic Usage
<template> <SbPagination v-model="currentPage" :total-pages="totalPages" /> </template> <script setup> import { ref } from 'vue'; const currentPage = ref(1); const totalPages = 10; </script>
With Results Info
<template> <SbPagination v-model="currentPage" :total-pages="totalPages" :per-page="perPage" :total="totalItems" show-info /> </template> <script setup> import { ref, computed } from 'vue'; const currentPage = ref(1); const perPage = 20; const totalItems = 157; const totalPages = computed(() => Math.ceil(totalItems / perPage)); </script>
Data Table Example
<template> <div> <!-- Table --> <table class="w-full"> <thead> <tr> <th>Name</th> <th>Email</th> </tr> </thead> <tbody> <tr v-for="user in paginatedUsers" :key="user.id"> <td>{{ user.name }}</td> <td>{{ user.email }}</td> </tr> </tbody> </table> <!-- Pagination --> <div class="mt-4"> <SbPagination v-model="currentPage" :total-pages="totalPages" :per-page="perPage" :total="users.length" @update:model-value="fetchPage" /> </div> </div> </template> <script setup> import { ref, computed } from 'vue'; const currentPage = ref(1); const perPage = 10; const users = ref([]); // Your data const totalPages = computed(() => Math.ceil(users.value.length / perPage)); const paginatedUsers = computed(() => { const start = (currentPage.value - 1) * perPage; return users.value.slice(start, start + perPage); }); const fetchPage = (page) => { // Fetch data for new page }; </script>
Custom Visible Pages
<template> <!-- Show more page numbers --> <SbPagination v-model="page" :total-pages="100" :on-each-side="3" /> <!-- Show fewer page numbers --> <SbPagination v-model="page" :total-pages="100" :on-each-side="1" /> </template>
Vue Props
| Prop | Type | Default | Description |
|---|---|---|---|
modelValue |
Number | 1 |
Current page (v-model) |
totalPages |
Number | required | Total page count |
perPage |
Number | 10 |
Items per page (for info) |
total |
Number | 0 |
Total items (for info) |
onEachSide |
Number | 2 |
Visible pages each side |
showInfo |
Boolean | true |
Show results info text |
Events
| Event | Payload | Description |
|---|---|---|
update:modelValue |
number |
Emitted when page changes |
Features
- Page Numbers: Shows current page with neighbors
- Ellipsis: Shows
...for skipped ranges - First/Last: Always shows first and last page
- Navigation: Previous/next buttons
- Results Info: "Showing X to Y of Z results"
Page Display Logic
With onEachSide: 2 and 20 total pages:
- Page 1:
1 2 3 ... 20 - Page 5:
1 ... 3 4 5 6 7 ... 20 - Page 20:
1 ... 18 19 20
Styling
Uses Tailwind CSS:
- White buttons with border
- Blue background for current page
- Disabled state for first/last page
- Hover effects
Requirements
- PHP 8.1+
- Laravel 10, 11, or 12
- Tailwind CSS 3.x
License
MIT License
mrshanebarron/pagination 适用场景与选型建议
mrshanebarron/pagination 是一款 基于 Vue 开发的 Composer 扩展包,目前已累计 13 次下载、GitHub Stars 达 0, 最近一次更新时间为 2025 年 12 月 14 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「pager」 「pagination」 「laravel」 「vue」 「livewire」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 mrshanebarron/pagination 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 mrshanebarron/pagination 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 mrshanebarron/pagination 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
Doctrine Collections adapter for Rekapager pagination library
Core functionality of Rekapager pagination library
Common classes for Symfony integration.
Symfony bundle for the Rekapager library
Doctrine DBAL adapter for Rekapager pagination library
Provides a Data Grid tables for your Symfony project.
统计信息
- 总下载量: 13
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 22
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2025-12-14