我是 laravel livewire 的新手。我正在尝试使用 livewire 切换模式。为此,我取了一个变量名 $isOpenModal
.最初它是错误的。当我单击单选时,输入 $isOpenModal
的值使用 $set('isOpenModal','true')
转为真.它成功打开了模态。当我单击关闭按钮时,我尝试使用 $set('isOpenModal','false')
关闭模式。 .但这不起作用。
这是我的代码
<div class="w-2/5 p-1 text-center " wire:click="$set('isOpenModal', 'true')">
<label class="labl">
<input type="radio" name="radioname" value="one_value"/>
<div class="rounded-lg py-2 px-3">{{trans('strings.change')}}</div>
</label>
</div>
<div class="d-flex justify-content-center align-items-center" >
<button wire:click="$set('isOpenModal', 'false')">
<div class="btn btn-danger">
<span class="text-base text-white-400 hover:text-white-300">{{trans('strings.close')}}</span>
</div>
</button>
</div>
如何在 $set method
中传递错误值.我试过传递 0 并且它的作品。但我需要使用 bool 值
最佳答案
您将 'true'/'false' 作为字符串传递。不带“”通过。
像这样
wire:click="$set('isOpenModal', true)"
希望能帮助到你。让我知道
关于javascript - 在 livewire 中的 $set 魔术 Action 中传递 bool 值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/63681229/