首页 > 解决方案 > @entangle 初始状态在内部视图侧始终设置为 true

问题描述

@entangle我想知道加载页面时值总是true在视图侧的原因可能是什么。当我们更改值时,行为是正常的。都在divs里面。如果我@entangle从初始化中正常提取它们。为了弥补我使用的x-init="show = @this.dshow"

Test.php


...
class Test extends Component
{
     public $dshow = false;
     ....
}

view.blade.php

<x-jet-dialog-modal>
    ...
   <x-slot name="content">
          <div style="max-height: 70vh">
                <div x-data="{ show : @entangle('dshow') }">
                     <label>
                         <input type="checkbox" value="1" wire:model="dshow" />
                         Check me
                     </label>
                     <div x-show="show">
                         This will be shown after you check abve
                     </div>
               </div>
          </div>
   </x-slot>
</x-jet-dialog-modal>

上面不会在加载时隐藏 div,但是在我们检查然后取消选中后,div 会按照我的意愿进行切换。我曾经x-init强制初始状态。可能是什么原因?它是一个错误吗?

标签: phplaravellaravel-livewirejetstream

解决方案


推荐阅读