Laravel Errorbag在刀片组件内部不工作

Laravel Errorbag在刀片组件内部不工作,laravel,laravel-blade,laravel-7,laravel-livewire,Laravel,Laravel Blade,Laravel 7,Laravel Livewire,我有一个Laravel Livewire组件,其中包括一个刀片组件,就像这样 {{$quick->name} @foreach($quick->问题作为$question) {{$question->question} @foreach($question->choices作为$choice) {{$choice->name} @endforeach @endforeach 这是我的刀片组件 创建新测验 {{--创建测验模式--} 创建新测验 &时代; @错误('question'){{

我有一个Laravel Livewire组件,其中包括一个刀片组件,就像这样


{{$quick->name}
@foreach($quick->问题作为$question)
{{$question->question}
@foreach($question->choices作为$choice)
{{$choice->name}
@endforeach

@endforeach
这是我的刀片组件


创建新测验
{{--创建测验模式--}
创建新测验
&时代;
@错误('question'){{$message}}@enderror
创造
这是我在
Livewire
类中使用的
store
方法

公共函数存储(){
//
$this->validate([
“问题”=>“必需|最小值:5”,
]);
问题::创建([
“问题”=>$this->问题,
“测验id”=>$this->quick->id
]);
$this->modalQuestionState=!$this->modalQuestionState;
$this->question=null;
}
调用存储时,验证失败,但由于某种原因,它不会在我的刀片组件中呈现

这是livewire网络的输出

errorBag: {question: ["The question must be at least 5 characters."]}
question: ["The question must be at least 5 characters."]

只需将此部分放在livewire组件上,而不是完整的模式。我也有同样的问题,通过这样做解决了

它应该能解决你的问题。让我知道

      <div>
           <div class="modal-content">
                <div class="modal-header">
                    <h5 class="modal-title">Create New Quiz</h5>
                    <button wire:click="modalCreateQuestionToggle" type="button" class="close" data-dismiss="modal" aria-label="Close">
                        <span aria-hidden="true">&times;</span>
                    </button>
                </div>
                <form wire:submit.prevent="store">
                    <div class="modal-body">
                        <input type="text" wire:model="question">
                        @error('question') <span class="error alert-danger">{{ $message }}</span> @enderror
                    </div>
                    <div class="modal-footer">
                        <button type="submit" class="btn btn-primary">Create</button>
                    </div>
                </form>

            </div>
      </div>

创建新测验
&时代;
@错误('question'){{$message}}@enderror
创造
这是我在liveware组件中的模式:

这是我的刀:


说明:这是因为当组件刷新时,livewire会为您提供刷新视图及其更改。在刷新的组件中,不再触发打开模式。所以你没有得到改变。因此,当您使用模态时,请确保在livewire组件中使用模态内容,以便打开的模态保持打开状态,其中的内容将被刷新。希望我向你讲清楚。如果你不够清楚,请告诉我

只需关闭模式并重新打开它,您就可以在那里看到错误。