Md.*_*ain 3 pagination server-side laravel laravel-pagination voyager
我正在使用 Laravel 8.4(“laravel/framework”:“^8.40”)和 Voyager 1.4(“tcg/voyager”:“^1.4”)进行开发。
\n我在 Laravel Voyager 中遇到了一个不寻常的错误。当我为任何 BREAD 激活服务器端分页时,分页链接部分会中断,如下所示:
\n\n\n但是,当我关闭服务器端分页时,它们正在工作,如下所示:
\n\n\n我在浏览器控制台或其他地方没有收到任何错误消息。
\n虽然“<<上一个”和“下一个>>”按钮按预期工作,但它们没有样式。
\n我已经检查了特定部分的 HTML。链接存在于此处,但由于某种原因未在浏览器中正确显示。该部分的 HTML 如下:
\n<div class="pull-right">\n <nav role="navigation" aria-label="Pagination Navigation" class="flex items-center justify-between">\n <div class="flex justify-between flex-1 sm:hidden">\n <a href="http://tabapp.test/admin/departments?sort_order=desc&showSoftDeleted=0&page=1" class="relative inline-flex items-center px-4 py-2 text-sm font-medium text-gray-700 bg-white border border-gray-300 leading-5 rounded-md hover:text-gray-500 focus:outline-none focus:ring ring-gray-300 focus:border-blue-300 active:bg-gray-100 active:text-gray-700 transition ease-in-out duration-150">\n \xc2\xab Previous\n </a>\n \n <a href="http://tabapp.test/admin/departments?sort_order=desc&showSoftDeleted=0&page=3" class="relative inline-flex items-center px-4 py-2 ml-3 text-sm font-medium text-gray-700 bg-white border border-gray-300 leading-5 rounded-md hover:text-gray-500 focus:outline-none focus:ring ring-gray-300 focus:border-blue-300 active:bg-gray-100 active:text-gray-700 transition ease-in-out duration-150">\n Next \xc2\xbb\n </a>\n </div>\n\n <div class="hidden sm:flex-1 sm:flex sm:items-center sm:justify-between">\n <div>\n <p class="text-sm text-gray-700 leading-5">\n Showing\n <span class="font-medium">16</span>\n to\n <span class="font-medium">30</span>\n of\n <span class="font-medium">67</span>\n results\n </p>\n </div>\n\n <div>\n <span class="relative z-0 inline-flex shadow-sm rounded-md">\n \n <a href="http://tabapp.test/admin/departments?sort_order=desc&showSoftDeleted=0&page=1" rel="prev" class="relative inline-flex items-center px-2 py-2 text-sm font-medium text-gray-500 bg-white border border-gray-300 rounded-l-md leading-5 hover:text-gray-400 focus:z-10 focus:outline-none focus:ring ring-gray-300 focus:border-blue-300 active:bg-gray-100 active:text-gray-500 transition ease-in-out duration-150" aria-label="&laquo; Previous">\n <svg class="w-5 h-5" fill="currentColor" viewBox="0 0 20 20">\n <path fill-rule="evenodd" d="M12.707 5.293a1 1 0 010 1.414L9.414 10l3.293 3.293a1 1 0 01-1.414 1.414l-4-4a1 1 0 010-1.414l4-4a1 1 0 011.414 0z" clip-rule="evenodd"></path>\n </svg>\n </a>\n \n \n \n \n \n <a href="http://tabapp.test/admin/departments?sort_order=desc&showSoftDeleted=0&page=1" class="relative inline-flex items-center px-4 py-2 -ml-px text-sm font-medium text-gray-700 bg-white border border-gray-300 leading-5 hover:text-gray-500 focus:z-10 focus:outline-none focus:ring ring-gray-300 focus:border-blue-300 active:bg-gray-100 active:text-gray-700 transition ease-in-out duration-150" aria-label="Go to page 1">\n 1\n </a>\n <span aria-current="page">\n <span class="relative inline-flex items-center px-4 py-2 -ml-px text-sm font-medium text-gray-500 bg-white border border-gray-300 cursor-default leading-5">2</span>\n </span>\n <a href="http://tabapp.test/admin/departments?sort_order=desc&showSoftDeleted=0&page=3" class="relative inline-flex items-center px-4 py-2 -ml-px text-sm font-medium text-gray-700 bg-white border border-gray-300 leading-5 hover:text-gray-500 focus:z-10 focus:outline-none focus:ring ring-gray-300 focus:border-blue-300 active:bg-gray-100 active:text-gray-700 transition ease-in-out duration-150" aria-label="Go to page 3">\n 3\n </a>\n <a href="http://tabapp.test/admin/departments?sort_order=desc&showSoftDeleted=0&page=4" class="relative inline-flex items-center px-4 py-2 -ml-px text-sm font-medium text-gray-700 bg-white border border-gray-300 leading-5 hover:text-gray-500 focus:z-10 focus:outline-none focus:ring ring-gray-300 focus:border-blue-300 active:bg-gray-100 active:text-gray-700 transition ease-in-out duration-150" aria-label="Go to page 4">\n 4\n </a>\n <a href="http://tabapp.test/admin/departments?sort_order=desc&showSoftDeleted=0&page=5" class="relative inline-flex items-center px-4 py-2 -ml-px text-sm font-medium text-gray-700 bg-white border border-gray-300 leading-5 hover:text-gray-500 focus:z-10 focus:outline-none focus:ring ring-gray-300 focus:border-blue-300 active:bg-gray-100 active:text-gray-700 transition ease-in-out duration-150" aria-label="Go to page 5">\n 5\n </a>\n \n \n <a href="http://tabapp.test/admin/departments?sort_order=desc&showSoftDeleted=0&page=3" rel="next" class="relative inline-flex items-center px-2 py-2 -ml-px text-sm font-medium text-gray-500 bg-white border border-gray-300 rounded-r-md leading-5 hover:text-gray-400 focus:z-10 focus:outline-none focus:ring ring-gray-300 focus:border-blue-300 active:bg-gray-100 active:text-gray-500 transition ease-in-out duration-150" aria-label="Next &raquo;">\n <svg class="w-5 h-5" fill="currentColor" viewBox="0 0 20 20">\n <path fill-rule="evenodd" d="M7.293 14.707a1 1 0 010-1.414L10.586 10 7.293 6.707a1 1 0 011.414-1.414l4 4a1 1 0 010 1.414l-4 4a1 1 0 01-1.414 0z" clip-rule="evenodd"></path>\n </svg>\n </a>\n </span>\n </div>\n </div>\n </nav>\n\n </div>Run Code Online (Sandbox Code Playgroud)\r\n我需要服务器端分页,因为会有大量来自后端的数据需要渲染。当行数超过 1K 时,只有客户端 DataTable 变得相当慢。
\n否则,我将需要考虑为许多需要此类数据处理的模型创建自定义 CRUD。
\n简单,在您的 AppServiceProvider 文件中插入两行:
use Illuminate\Pagination\Paginator;
public function boot(){
Paginator::useBootstrap();
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
1782 次 |
| 最近记录: |