laravel版本:5.5.。

执行命令:

php artisan vendor:publish --tag=laravel-pagination

  

在到 resources/views/vendor/pagination 下找到default.blade.php文件。进行自定义分页样式编辑

修改后代码:

@if ($paginator->hasPages())
<ul class="pagination">
{{--首页--}}
@if ($paginator->onFirstPage())
<li class="disabled"><span>首页</span></li>
@else
<li><a href="{{ $paginator->url(1) }}" rel="prev">首页</a></li>
@endif {{-- Previous Page Link --}}
@if ($paginator->onFirstPage())
<li class="disabled"><span>上页</span></li>
@else
<li><a href="{{ $paginator->previousPageUrl() }}" rel="prev">上页</a></li>
@endif {{-- Pagination Elements --}}
@foreach ($elements as $element)
{{-- "Three Dots" Separator --}}
@if (is_string($element))
<li class="disabled"><span>{{ $element }}</span></li>
@endif {{-- Array Of Links --}}
@if (is_array($element))
@foreach ($element as $page => $url)
@if ($page == $paginator->currentPage())
<li class="active"><span>{{ $page }}</span></li>
@else
<li><a href="{{ $url }}">{{ $page }}</a></li>
@endif
@endforeach
@endif
@endforeach {{-- Next Page Link --}}
@if ($paginator->hasMorePages())
<li><a href="{{ $paginator->nextPageUrl() }}" rel="next">下页</a></li>
@else
<li class="disabled"><span>下页</span></li>
@endif
{{--末页--}}
@if ($paginator->hasMorePages())
<li><a href="{{ $paginator->url($paginator->lastPage()) }}" rel="next">末页</a></li>
@else
<li class="disabled"><span>末页</span></li>
@endif
</ul>
@endif

  最总效果截图:

laravel自定义分页功能的实现:-LMLPHP

亲测可用,如有问题请留言,谢谢

05-11 18:23