[英]how can i get how many checkboxes are checked in laravel livewire
在您的组件中,您希望有一个数组来保存选定的复选框:
public array $selectedItems = [];
然后,在您的刀片中,您希望将复选框链接到此数组:
<input type="checkbox" value="{{ $item->id }}" wire:model="selectedItems">
现在您可以在刀片中使用count($selectedItems)
或在组件中使用count($this->selectedItems)
来了解选择了多少。
尝试这样的事情
<input
id="my-id"
wire:model="yourCheckboxModel"
type="checkbox"
@if($yourLivewireVariable)
checked
@endif>
您可以使用刀片 if endif 语句来切换选中的变量,然后使用线 model 绑定变量
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.