【发布时间】: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->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->links() }}使用默认视图时会出现同样的问题
标签: php laravel laravel-livewire