同一页面上多个组件的 Livewire 分页问题
P粉714780768
P粉714780768 2023-09-01 12:49:12
0
1
337
<p>在同一页面上使用两个分页组件时,我遇到了 Livewire 分页问题。我遵循了 Livewire 文档关于使用多个分页器的建议。但是,每当我尝试导航到其中一个组件上的页面时,我都会遇到两个问题:</p> <ul> <li>第一次导航时,它按预期工作,但后续尝试不会重定向;</li> <li>分页导航的链接在第一次重定向后消失;</li> <li>如果我手动更改 URL,组件会反映更改并显示正确的页面。尽管单击组件本身的页面仅在第一次有效。</li> </ul> <p>另一个组件按预期运行,其创建方式与显示所描述问题的组件相同。</p> <p>我尝试遵循文档和调试,但没有任何进展。这是我的代码的简化版本,它大致基于文档。</p> <p><strong>ActivityLogs.php</strong></p> <pre class="brush:php;toolbar:false;">class ActivityLogs extends Component { use WithPagination; public Model $model; private ActivityLogRepository $activityLogRepository; public function boot(ActivityLogRepository $activityLogRepository): void { $this-&gt;activityLogRepository = $activityLogRepository; } public function mount(Model $model): void { $this-&gt;model = $model; } public function render(): View { return view('livewire.activity-logs.activity-logs', [ 'activities' =&gt; $this-&gt;activityLogRepository -&gt;getLogsForModel($this-&gt;model) -&gt;paginate(5, pageName: 'activityPage'), ]); } }</pre> <p><strong>activity-logs.blade.php</strong></p> <pre class="brush:php;toolbar:false;">&lt;x-cards.simple class=&quot;col-span-6 lg:col-span-3 xl:col-span-2 overscroll-contain&quot; max-height=&quot;lg&quot; title=&quot;{{ __('Activity Logs') }}&quot; icon=&quot;project&quot; &gt; &lt;div class=&quot;my-2 pr-2 h-full lg:max-h-[300px]&quot;&gt; @if($activities-&gt;isNotEmpty()) @foreach($activities as $activity) @dump($activity) @endforeach &lt;div class=&quot;mt-8&quot;&gt; {{ $activities-&gt;onEachSide(1)-&gt;links() }} &lt;/div&gt; @else &lt;span&gt; {{ __('This model has no logged activities.') }} &lt;/span&gt; @endif &lt;/div&gt; &lt;/x-cards.simple&gt;</pre> <p>如果您能了解我为何面临上述问题,我将不胜感激。谢谢!</p>
P粉714780768
P粉714780768

Derniers téléchargements
Plus>
effets Web
Code source du site Web
Matériel du site Web
Modèle frontal
À propos de nous Clause de non-responsabilité Sitemap
Site Web PHP chinois:Formation PHP en ligne sur le bien-être public,Aidez les apprenants PHP à grandir rapidement!