【问题标题】:Livewire Pagination removes URL PartLivewire 分页删除 URL 部分
【发布时间】:2021-06-23 01:06:37
【问题描述】:

我有这个组件来呈现分页结果:

<?php

namespace App\Http\Livewire\Accounts;

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

class Index extends Component
{
    use WithPagination;
    public $search;
    public $accounts;

    public function render()
    {
        if ($this->search) {
            $this->resetPage();
            $this->accounts = Account::search($this->search)
                ->orWhere('fullname', 'LIKE', '%'.$this->search.'%')
                ->orWhere('email', 'LIKE', '%'.$this->search.'%')->orderBy('fullname')->paginate(12);
        } else {
            $this->accounts = Account::orderBy('fullname')->paginate(12);
        }

        return view('livewire.accounts.index', ['accounts' => $this->accounts]);
    }
}

在 Blade 模板中我有 {{ $accounts-&gt;links('pagination.tailwind') }} 分页视图是 vendor/livewire/tailwind.blade.php 的副本

网址是 http://mydomain.com/accounts。

当我点击分页链接时,URL 变为 htttp://mydomain.com/?page=2 而不是 htttp://mydomain.com/accounts/?page=2

【问题讨论】:

  • 您是否以任何方式更改了分页刀片视图?
  • 只更改了一些 CSS 类,但 {{ $accounts-&gt;links() }} 使用默认视图时会出现同样的问题

标签: php laravel laravel-livewire


【解决方案1】:

我遇到了同样的问题,但现在我建议在您的父组件中添加 use WithPagination 并且它正在工作。 问题是我认为这不是一个好方法 You can follow the issue in GitHub with @calebporzio

希望对你有帮助

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2012-02-26
    • 1970-01-01
    • 2014-07-05
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多