分页链接在 Laravel Livewire 中无法正常工作

Pagination links is not working properly in Laravel Livewire

我正在使用 Laravel 9 和 Livewire 2.x。分页 link 无法正常工作;它只改变一项。我尝试将地址栏上的 link 更改为 /search?query=example&page=2,并且效果很好。

组件Class

use Livewire\Component;
use App\Models\Product;
use Livewire\WithPagination;

class Search extends Component
{
    use WithPagination;

    protected $paginationTheme = 'bootstrap';
    public $query;

    protected $queryString = ['query'];
    public function render()
    {
        $products = $this->searchQuery($this->query);
        return view('livewire.products.search', [
            'products' => $products->paginate(6),
        ])->extends('layouts.buyer')->section('content');
    }

    public function mount()
    {
    }

    public function searchQuery($input){
        return Product::where('name','like','%' . $input . '%' );
    }
}

查看

<div class="container my-5">
    @if($products->isNotEmpty())
        <div class="row g-4">
            @foreach($products as $product)
            <div class="col-lg-3">
                @livewire('products.buyer-product-item', ['product' => $product])
            </div>
            @endforeach

        </div>
    @else
    <div class="alert alert-danger">Product Was Not Found !!!</div>
    @endif
    <nav class="mt-5" aria-label="Page navigation example">
        {{ $products->links() }}
    </nav>
</div>

嘿,查看控制台后发现有错误。 无法读取 null

的 属性 'fingerprint'

包含嵌套组件的密钥后,问题就解决了。

@livewire('products.buyer-product-item', ['product' => $product], key($product->id))