laravel 警报在视图页面中不起作用

In laravel alert not working in view page

我在自定义注册表单中使用提醒以获取唯一电子邮件,phone-不,但它不起作用

代码无效

@if ($errors->has('email'))
<span class="invalid-feedback" role="alert">
<strong>{{ $errors->first('email') }}</strong>
</span>
@endif

@if ($errors->has('phone'))
<span class="invalid-feedback" role="alert">
<strong>{{ $errors->first('phone') }}</strong>
</span>
@endif

当我在下面的代码下使用时,它可以工作,但它显示输入区域下方的所有错误,

代码

 @if($errors->has('email'))
    @foreach($errors->all() as $error)
        <li style="color:red">{{ $error }}</li>
    @endforeach 
@endif

  @if($errors->has('phone'))
        @foreach($errors->all() as $error)
            <li style="color:red">{{ $error }}</li>
        @endforeach 
    @endif

尝试下面的示例显示个别错误

 @if ($errors->any())
   <label for="email" class="error">{{ $errors->first('email') }}</label> 
 @endif

 @if ($errors->any())
       <label for="phone" class="error">{{ $errors->first('phone') }}</label> 
 @endif