javascript - 在 livewire 中的 $set 魔术 Action 中传递 bool 值

标签 javascript html laravel laravel-livewire

我是 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/

相关文章:

php - 你能在 laravel 中创建一个范围来调用其他各种范围吗?

laravel - Vapor - 如何增加部署到登台和生产的文件夹大小?

php - Javascript 不会在 php 页面上运行

javascript - 如何在vue中更新chart.js

javascript - 推荐一个HTML5/Javascript的开发环境?

javascript - Canvas 在边缘上 Blob

python - 使用 css 选择器提取具有特定类的链接

laravel - request()->json() 和 request()->input() 有什么区别

javascript - 关于捕获错误的异步和等待和 promise

php - Wordpress 基本概念 - 如何扩展/覆盖/自定义插件 Hook ?