我使用laravel默认分页:
{{$posts->links()}}
和分页工作,链接出现,它的工作正确。
但风格是这样的:
你知道为什么不使用bootstrap 4默认样式吗?我使用的是Bootstrap 4.
此外,我还有内部视图/供应商/分页文件:
- bootstrap4-blade.php
-default.blade.php
-semantic-ui.blade.php
-simple-bootstra-4.blade.php
-simple-default.blade.php
生成的HTML:
<ul class="pagination">
<li class="disabled"><span>«</span></li>
<li class="active"><span>1</span></li>
<li><a href="http://proj.test/user/profile?page=2">2</a></li>
<li><a href="http://proj.test/user/profile?page=2" rel="next">»</a></li>
</ul>
In&#34; http://proj.test/css/app.css&#34;看来:
.pagination {
display: -webkit-box;
display: -ms-flexbox;
display: flex;
padding-left: 0;
list-style: none;
border-radius: 0.25rem;
}
.page-item:first-child .page-link {
margin-left: 0;
border-top-left-radius: 0.25rem;
border-bottom-left-radius: 0.25rem;
}
.page-item:last-child .page-link {
border-top-right-radius: 0.25rem;
border-bottom-right-radius: 0.25rem;
}
.page-item.active .page-link {
z-index: 2;
color: #fff;
background-color: #0FACF3;
border-color: #0FACF3;
}
.page-item.disabled .page-link {
color: #868e96;
pointer-events: none;
background-color: #fff;
border-color: #ddd;
}
.page-link {
position: relative;
display: block;
padding: 0.5rem 0.75rem;
margin-left: -1px;
line-height: 1.25;
color: #0FACF3;
background-color: #fff;
border: 1px solid #ddd;
}
.page-link:focus,
.page-link:hover {
color: #097aad;
text-decoration: none;
background-color: #e9ecef;
border-color: #ddd;
}
.pagination-lg .page-link {
padding: 0.75rem 1.5rem;
font-size: 1.25rem;
line-height: 1.5;
}
.pagination-lg .page-item:first-child .page-link {
border-top-left-radius: 0.3rem;
border-bottom-left-radius: 0.3rem;
}
.pagination-lg .page-item:last-child .page-link {
border-top-right-radius: 0.3rem;
border-bottom-right-radius: 0.3rem;
}
.pagination-sm .page-link {
padding: 0.25rem 0.5rem;
font-size: 0.875rem;
line-height: 1.5;
}
.pagination-sm .page-item:first-child .page-link {
border-top-left-radius: 0.2rem;
border-bottom-left-radius: 0.2rem;
}
.pagination-sm .page-item:last-child .page-link {
border-top-right-radius: 0.2rem;
border-bottom-right-radius: 0.2rem;
}
在页面加载中:
<link href="https://maxcdn.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css" rel="stylesheet">
<link href="https://fonts.googleapis.com/css?family=Nunito:200,400,600,700" rel="stylesheet">
<link href="http://proj.test/css/app.css" rel="stylesheet" type="text/css">
<link href="http://proj.test/css/toastr.min.css" rel="stylesheet" type="text/css">
<link href="http://proj.test/css/bootstrap-datetimepicker.css" rel="stylesheet" />
答案 0 :(得分:2)
您可以自定义用于显示分页的视图,将其作为links
方法的参数传递:
{{ $paginator->links('your.view') }}
您甚至可以使用Paginator::defaultView
中的AppServiceProvider
自定义应用的默认视图:
use Illuminate\Pagination\Paginator;
public function boot()
{
Paginator::defaultView('pagination::view');
}
查看docs以获取更多信息。
答案 1 :(得分:1)
由于视图尚不可用,我们需要发布视图。请在终端/CMD中运行以下命令:
php artisan vendor:publish --tag=laravel-pagination