【发布时间】:2020-10-02 02:34:06
【问题描述】:
这里是菜鸟。请帮忙。
当我在输入框中搜索东西时,再次清除输入框。然后我单击任何分页元素:1、2、3、4、5,我收到此错误。
此路由不支持 GET 方法。支持的方法:POST。
这是 livewire 组件
search.blade.php
@if ($paginator->hasPages())
<nav>
<ul class="pagination">
{{--Previous Page Link--}}
@if ($paginator->onFirstPage())
<li class="page-item disabled" aria-disabled="true" aria-label="@lang('pagination.previous')">
<li class="page-item disabled" aria-disabled="true">
<span class="page-link" aria-hidden="true">‹</span>
</li>
@else
<li class="page-item">
<button class="page-link" wire:click="previousPage" rel="prev">‹</button>
</li>
@endif
{{--Pagination Elements--}}
@foreach ($elements as $element)
{{--"Three Dots" Separator--}}
@if (is_string($element))
<li class="page-item disabled" aria-disabled="true"><span class="page-link">{{ $element }}</span></li>
@endif
{{--Array Of Links--}}
@if (is_array($element))
@foreach ($element as $page => $url)
@if ($page == $paginator->currentPage())
<li class="page-item active" aria-current="page"><span class="page-link">{{ $page }}</span></li>
@else
<li class="page-item"><a class="page-link" href="{{ $url }}">{{ $page }}</a></li>
@endif
@endforeach
@endif
@endforeach
{{--Next Page Link--}}
@if ($paginator->hasMorePages())
<li class="page-item">
<button class="page-link" wire:click="nextPage" rel="next" aria-label="@lang('pagination.next')">›</button>
</li>
@else
<li class="page-item disabled" aria-disabled="true" aria-label="@lang('pagination.next')">
<li class="page-item disabled" aria-disabled="true">
<span class="page-link" aria-hidden="true">›</span>
</li>
@endif
</ul>
</nav>
@endif
搜索-students.blade.php
{{-- CARD BODY --}}
<div class="card-body">
<div id="example1_wrapper" class="dataTables_wrapper dt-bootstrap4">
<div class="row">
<div class="col-sm-12 col-md-6">
<div id="example1_filter" class="dataTables_filter">
<label>Search:<input type="search" class="form-control form-control-sm" placeholder="" wire:model="searchText">
</label>
</div>
</div>
</div>
<div class="row">
<div class="col-sm-12">
<table id="example1" class="table table-bordered table-striped dataTable dtr-inline" role="grid"
aria-describedby="example1_info">
<thead>
<tr role="row">
<th class="sorting_asc" tabindex="0" aria-controls="example1" rowspan="1" colspan="1" aria-sort="ascending">First Name</th>
<th class="sorting" tabindex="0" aria-controls="example1" rowspan="1" colspan="1">Last Name</th>
<th class="sorting" tabindex="0" aria-controls="example1" rowspan="1" colspan="1">Image</th>
</thead>
<tbody>
@foreach($students as $student)
<tr role="row" class="odd">
<td class="sorting_1 dtr-control">{{ $student->FirstName }}</td>
<td>{{ $student->LastName }}</td>
<td><img src="StudentImage/{{ $student->ImageLink }}.jpg" width="120" height="150"></td>
</tr>
@endforeach
</tbody>
<tfoot>
<tr>
</tfoot>
</table>
</div>
</div>
<div class="col-sm-12 col-md-7">
{{ $students->links('livewire.livewire-pagination') }}
</div>
</div>
</div>
</div>
{{-- card body --}}
【问题讨论】:
-
下一页和上一页按钮是否有效?
-
你能不能把你的组件代码也放上去
search -
@GiovanniS。是的,他们正在工作。
-
@KamleshPaul 好的。我将包含组件代码。
-
我遇到了同样的问题。这对我来说很有效:laptrinhx.com/… 这是一种不同的方法,但它有效。
标签: laravel