Radio Livewire Laravel – 无法获取收音机数值

huangapple go评论51阅读模式
英文:

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

&lt;livewire:frontend.product.index :category=&quot;$category&quot;/&gt;

its binding with livewire to livewire/frontend/product/index

&lt;div class=&quot;card-header bg-white mt-3&quot;&gt;
                &lt;h4&gt;Price&lt;/h4&gt;
                &lt;div class=&quot;card-body&quot;&gt;
                    &lt;label class=&quot;d-block&quot; for=&quot;&quot;&gt;
                        &lt;input type=&quot;radio&quot; name=&quot;priceSort&quot; class=&quot;me-3&quot; wire:model=&quot;priceInput&quot;
                            value=&quot;high-to-low&quot;&gt;High to Low

                            check : {{var_export(($priceInput))}}
                    &lt;/label&gt;
                    &lt;label class=&quot;d-block&quot; for=&quot;&quot;&gt;
                        &lt;input type=&quot;radio&quot; name=&quot;priceSort&quot; class=&quot;me-3&quot; wire:model=&quot;priceInput&quot;
                            value=&quot;low-to-high&quot;&gt;Low to High
                    &lt;/label&gt;
                &lt;/div&gt;
            &lt;/div&gt;

i want to get the "low-to-high" value from the radio but it seems like the
check : {{var_export(($priceInput))}} is null
Radio Livewire Laravel – 无法获取收音机数值

here is my livewire controller code

class Index extends Component
{
    public $category, $products;

    public $priceInput;

return view(&#39;livewire.frontend.product.index&#39;, [
            &#39;products&#39; =&gt; $this-&gt;products,
            &#39;category&#39; =&gt; $this-&gt;category,
        ]);
}

thanks for the answer

答案1

得分: 1

已解决,我已经找到了,我需要在<head>中输入

@livewireStyles

和在<body>中输入

@livewireScripts
英文:

its solved, i already found it i need to input

 @livewireStyles

in the &lt;head&gt;

and

@livewireScripts

in the &lt;body&gt;

huangapple
  • 本文由 发表于 2023年6月15日 20:07:57
  • 转载请务必保留本文链接:https://go.coder-hub.com/76482313.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定