怎么实现分页按钮类似于这样,写出了个代码

不能传截图,类似下边的

15页,到第【】页上一页1 26 7 8 9 1013 14下一页

代码

@if($users->currentPage() == 1)
<a class="prev disabled" href="javascript:void(0);">上一页</a>
@else
<a class="prev" href="{!! $users->url($users->currentPage()-1) !!}">上一页</a>
@endif
@for ($i = 1; $i < $users->lastPage(); $i++)
@if($i<=2 || ($users->lastPage()-$i)<=2)
@if($i == $users->currentPage())
<a class="active" href="javascript:void(0);">{$i}</a>
@else
<a href="{!! $users->url($i) !!}">{$i}</a>
@endif
@else
@if(abs($users->currentPage()-$i) <3)
@if($i == $users->currentPage())
<a class="active" href="javascript:void(0);">{$i}</a>
@else
<a href="{!! $users->url($i) !!}">{$i}</a>
@endif
@else
@if($i == 3 || ($users->lastPage()-$i) == 3)
<span>…</span>
@endif
@endif
@endif
@endfor
@if($users->lastPage() == $users->currentPage())
<a class="next disabled" href="javascript:void(0);">下一页</a>
@else
<a class="next" href="{!! $users->nextPageUrl() !!}">下一页</a>
@endif
sswowo

自己新建分页的模板 然后根据下面提供的方法 组织出你想要的效果嘛

$results->count()
$results->currentPage()
$results->hasMorePages()
$results->lastPage() (Not available when using simplePaginate)
$results->nextPageUrl()
$results->perPage()
$results->previousPageUrl()
$results->total() (Not available when using simplePaginate)
$results->url($page)

参考:http://www.golaravel.com/laravel/docs/5.1/pagination/