我在读一本书,我很沮丧,因为它不会改变我的书页。
我创建了一个新的资源控制器,我的索引方法如下:
public function index()
{
$events = Event::paginate(10);
return view('events.index')->with('events', $events);
}
在我的index.blade.php中
@extends('layouts.app')
@section('content')
<h1>Events</h1>
<ul>
@forelse($events as $event)
<li>{{ $event->name }}</li>
@empty
<li>No events found!</li>
@endforelse
</ul>
{!! $events->links() !!} // links are generate 1 2 3 4 but cannot navigate only the first page is displayed
@endsection
更新:生成的html
<ul class="pagination" role="navigation">
<li class="page-item disabled" aria-disabled="true" aria-label="« Previous">
<span class="page-link" aria-hidden="true">‹</span>
</li>
<li class="page-item active" aria-current="page"><span class="page-link">1</span></li>
<li class="page-item"><a class="page-link" href="http://localhost/events?page=2">2</a></li>
<li class="page-item"><a class="page-link" href="http://localhost/events?page=3">3</a></li>
<li class="page-item"><a class="page-link" href="http://localhost/events?page=4">4</a></li>
<li class="page-item"><a class="page-link" href="http://localhost/events?page=5">5</a></li>
<li class="page-item"><a class="page-link" href="http://localhost/events?page=6">6</a></li>
<li class="page-item">
<a class="page-link" href="http://localhost/events?page=2" rel="next" aria-label="Next »">›</a>
</li>
</ul>
暂无答案!
目前还没有任何答案,快来回答吧!