Laravel 8结合Bootstrap分页无法跳转至最后一页及倒数第三页问题
Laravel 8 Bootstrap分页无法跳转至最后一页问题
此前我开发过一个Laravel 8应用,使用Bootstrap分页功能,当时数据库只有约40条数据,分页运行正常。现在我新开发了一个应用,数据库内有300020条数据,分页页数相较之前更多,但出现了无法跳转至最后一页的问题,仅能跳转至页码更小的页面,效果如下图:
我不清楚为什么分页组件不允许我跳转至最后一页以及倒数第三页,异常现象截图如下:
我使用的是links()方法实现分页渲染,前端模板代码如下:
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta http-equiv="X-UA-Compatible" content="IE=edge"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>Employees</title> <link href="{{ mix('css/app.css') }}" rel="stylesheet" type="text/css" /> </head> <body> {{ $employees->total() }} <div class="container"> <div class="row"> <div class="col-sm-4"></div> <div class="col-sm-4"> <table class="table"> <thead class="thead-dark"> <th>Emp_no</th> <th>First Name</th> <th>Last Name</th> <th>Hire Date</th> </thead> <tbody> @foreach($employees as $employee) <tr> <td>{{ $employee->emp_no }}</td> <td>{{ $employee->first_name }}</td> <td>{{ $employee->last_name }}</td> <td>{{ $employee->hire_date }}</td> </tr> @endforeach </tbody> </table> <hr> {{ $employees->links() }} </div> <div class="col-sm-4"></div> </div> </div> <!-- Bootstrap JS, jquery y popper compiled --> <script src="{{ mix('js/app.js') }}" type="text/javascript"></script> </body> </html>
控制器代码如下:
class EmployeeController extends Controller { public function index() { $employees = Employee::query()->Paginate(5); return view('employee.index', compact('employees')); } }
模型代码如下(我向数据库导入了一张现成的业务表):
class Employee extends Model { use HasFactory; protected $table = 'employees'; protected $primaryKey = 'emp_no'; }
我习惯在有数千条数据的场景下测试应用,如果大家有解决这个问题的思路,麻烦告知我,非常感谢。
内容的提问来源于stack exchange,提问作者Freddy Daniel
相关产品推荐
相关产品推荐

