Livewire 线:model.defer 在提交时显示空值(第二次)

Mat*_*zar 5 php laravel laravel-livewire

这是我的刀片视图示例

<x-jet-form-section submit="store">
    <div class="col-span-6 sm:col-span-4">
                <x-jet-label for="name" value="{{ __('Name') }}" />
                <x-jet-input name="name" wire:model.defer="name" type="text" class="mt-1 block w-full" autocomplete="off" />
                <x-jet-input-error for="name" class="mt-2" />
            </div>
</x-jet-form-section>
Run Code Online (Sandbox Code Playgroud)

在 LiveWire 组件上我有这个调试

public function store() {
  dd($this);
}
Run Code Online (Sandbox Code Playgroud)

当我提交表单时,我看到输入字段值。然后我关闭调试窗口(dd)再次按提交,现在该值为NULL。

如果我将wire:model.defer更改为wire:model.lazy,这种情况就不会再发生。有用。为什么 ?!

Viv*_* ab 0

使用wire:model.lazy而不是wire:model.defer这个将解决你的问题