我不確定我的問題是否措辭得當,但我正在定制分頁,到目前為止,我在我的視圖中這樣做了,而且效果不錯。
@if($paginator->hasPages()
<div class="pagination" >
@if ($paginator->currentPage( ) > 1)
<a href="">« </a>
@else
<a href=" style="opacity:0. 5; pointer-events:none;">«< /a>
@endif
<a class="active" href="">1</a>
<a href="">2</a>
<a href="">3</a>
<a href="">4</a>
<a href="">5</a>
@if (!$paginator->hasMorePages()
<a href=" style="opacity:0. 5; pointer-events:none;">»< /a>
@else
<a href="">» </a>
@endif
</div>
@endif
正如你所看到的,頁面鏈接是硬編碼的。我怎樣才能動態地顯示它們?
uj5u.com熱心網友回復:
>。嘗試用
替換所有這些內容@if($paginator-> hasPages())
{!! $paginator->render(); !}
@endif
你也可以
@if($paginator->hasPages()
<div class="pagination">/span>
@if ($paginator->currentPage() > 1)
<a href="{{$paginator-> previousPageUrl()}}">«< /a>
替換
<a href="{{$paginator-> url(1)}}" style="opacity: 0. 5; pointer-events:none;">«</a>
@endif
@if($paginator->currentPage()-2 >0)
<a href="{$paginator->url($paginator-> currentPage()-2)}}">{{$paginator->currentPage()-2}}</a>/span>
@endif
@if($paginator->currentPage()-1 >0)
<a href="{$paginator->url($paginator-> currentPage()-1)}">{{$paginator->currentPage()-1}}</a>/span>
@endif
<a class="active"/span> href="#"/span>> {{$paginator->currentPage()}}</a>/span>
@if($paginator->currentPage() 1 <=$paginator->lastPage())
<a href="{$paginator->url($paginator-> currentPage() 1)}">{{$paginator->currentPage() 1}}</a>/span>
@endif
@if($paginator-> currentPage() 2 <=$paginator->lastPage()
<a href="{$paginator->url($paginator-> currentPage() 2)}}">{{$paginator->currentPage() 2}}</a>/span>
@endif
@if (!$paginator->hasMorePages()
<a href="{{$paginator-> url($paginator->lastPage())}}" style="opacity: 0. 5; pointer-events:none;">»</a>
替換
<a href="{{$paginator-> nextPageUrl()}}">»</a> /span>
@endif
</div> @endif
@endif
這段代碼不是百分之百的干凈,但你可以理解(特別是圍繞著$paginator->hasMorePages())。
轉載請註明出處,本文鏈接:https://www.uj5u.com/gongcheng/307808.html
標籤:
