Laravel 5.6 Flash消息必须自动关闭

问题描述

这是我第一次开发东西,所以第一次使用laravel。 现在,我发出了flash_error消息,我希望这些消息在3秒后关闭。不知道该怎么做。

这是我随后在控制器中编写的方式:

return redirect('/admin/settings')->with('flash_message_error','Incorrect Current Password!');

这是我在blade.PHP页面添加的方式:

@if(Session::has('flash_message_error'))
    <div class="alert alert-error alert-block">
        <button type="button" class="close" data-dismiss="alert">×</button> 
        <strong>{!! session('flash_message_error') !!}</strong>
    </div>
@endif 

现在的问题是,我如何自动关闭然后该怎么做

解决方法

像这样使用Jquery

$("document").ready(function(){
    setTimeout(function(){
       $("div.alert").remove();
    },3000 ); // 3 secs

});