英文:
Radio Livewire Laravel - Cant get the radio value
问题
这段代码来自我的资源/views/collection:
<livewire:frontend.product.index :category="$category"/>
它与 livewire 绑定到 livewire/frontend/product/index。
<div class="card-header bg-white mt-3">
<h4>Price</h4>
<div class="card-body">
<label class="d-block" for="">
<input type="radio" name="priceSort" class="me-3" wire:model="priceInput" value="high-to-low">High to Low
check : {{var_export(($priceInput))}}
</label>
<label class="d-block" for="">
<input type="radio" name="priceSort" class="me-3" wire:model="priceInput" value="low-to-high">Low to High
</label>
</div>
</div>
我想从单选按钮中获取"value"为 "low-to-high" 的值,但似乎check : {{var_export(($priceInput))}}
是空的。
这是我的 Livewire 控制器代码:
class Index extends Component
{
public $category, $products;
public $priceInput;
return view('livewire.frontend.product.index', [
'products' => $this->products,
'category' => $this->category,
]);
}
感谢答案。
英文:
this code is from my resources/views/collection
<livewire:frontend.product.index :category="$category"/>
its binding with livewire to livewire/frontend/product/index
<div class="card-header bg-white mt-3">
<h4>Price</h4>
<div class="card-body">
<label class="d-block" for="">
<input type="radio" name="priceSort" class="me-3" wire:model="priceInput"
value="high-to-low">High to Low
check : {{var_export(($priceInput))}}
</label>
<label class="d-block" for="">
<input type="radio" name="priceSort" class="me-3" wire:model="priceInput"
value="low-to-high">Low to High
</label>
</div>
</div>
i want to get the "low-to-high" value from the radio but it seems like the
check : {{var_export(($priceInput))}}
is null
here is my livewire controller code
class Index extends Component
{
public $category, $products;
public $priceInput;
return view('livewire.frontend.product.index', [
'products' => $this->products,
'category' => $this->category,
]);
}
thanks for the answer
答案1
得分: 1
已解决,我已经找到了,我需要在<head>
中输入
@livewireStyles
和在<body>
中输入
@livewireScripts
英文:
its solved, i already found it i need to input
@livewireStyles
in the <head>
and
@livewireScripts
in the <body>
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论