如何解决Laravel 8 UI分页问题?

在尝试最近发布的laravel 8时遇到问题,我试图找出所做的更改以及其工作方式。当我这样做时,我遇到了一个问题,即分页的laravel 8用户界面变得混乱,并且以某种方式发生了。有谁可以帮助我吗?或经历过同样的事情?

就像这样,我在laravel 8中看到的视图 Laravel 8 paginate UI

这是我使用的代码“ Index.blade.php”

@extends('layouts.app')

@section('title','Post')

@section('contents')

    <div class="container">
        <div class="row">
            @foreach ($posts as $post)
                <div class="col-md-4 mb-4">
                    <div class="row">
                        <div class="card mb-4">
                            <div class="card-header">
                                {{ $post->title }}
                            </div>
                            <div class="card-body">
                                {{ $post->body }}
                            </div>
                            <div class="card-footer">
                                {{ $post->created_at->diffForHumans() }}
                            </div>
                        </div>
                    </div>
                </div>
            @endforeach
        </div>
        <div class="d-felx justify-content-center">

            {{ $posts->links() }}

        </div>
    </div>

@endsection

我用于PostController的代码

<?php

namespace App\Http\Controllers;

use App\Models\Posts;
use Illuminate\Http\Request;

class PostsController extends Controller
{
    public function index()
    {
        $posts = Posts::latest()->paginate(6);
        // dd($post);
        return view('post.index',compact('posts'));
    }
}
iCMS 回答:如何解决Laravel 8 UI分页问题?

我尝试在 df.groupby("city")["timeDiff"].mean() 中添加 Paginator::useBootstrap();,但没有奏效。

但这奏效了:

AppServiceProvider.php
,

我遇到了同样的问题。

好像在Laravel 8中一样,增加了更多显示分页的选项。

此说明https://laravel.com/docs/8.x/pagination#using-bootstrap应该会有所帮助。

,

请确保您在AppServiceProvider中具有此名称。

use Illuminate\Pagination\Paginator;

public function boot()
{
     Paginator::useBootstrap();
}

您很高兴。

,

对于 Laravel 8 及以上版本,只需搜索 AppServiceProvider.php 并将这些代码添加到其中:

use Illuminate\Pagination\Paginator;

public function boot()
{
    Paginator::useBootstrap();
}

或直接在您的刀片文件中使用它:

$posts->links('pagination::bootstrap-4')
,

使用引导程序

Laravel 包含使用 Bootstrap CSS 构建的分页视图。要使用这些视图而不是默认的 Tailwind 视图,您可以在 useBootstrap 类的 boot 方法中调用分页器的 App\Providers\AppServiceProvider 方法:

use Illuminate\Pagination\Paginator;

/**
 * Bootstrap any application services.
 *
 * @return void
 */
public function boot()
{
    Paginator::useBootstrap();
}

此说明https://laravel.com/docs/8.x/pagination#using-bootstrap应该可以帮助您如何添加分页并可以显示..

,

以下实现对我有用,在您的“app\Providers\AppServiceProvider.php”中,请尝试。

use Illuminate\Pagination\Paginator;

public function boot()
{

 Paginator::use Bootstrap();

}
,

只需转到 App/providers 并在 AppServiceProvider 中使用以下代码

use Illuminate\Pagination\Paginator;

public function boot()
{
    Paginator::useBootstrap();
}
,

首先进入文件 app\Providers\AppServiceProvider.php

然后添加:

use Illuminate\Pagination\Paginator;

public function boot()
{
    Paginator::use Bootstrap();
}

{{ $blogs->links() }} // Using it After @endforeach in your post.blade.php
,

分页器::useBootstrap(); 100%

本文链接:https://www.f2er.com/1588417.html

大家都在问