Javascript $page.props.csrf_令牌未定义(inertiajs)
我想将用户注销到非惯性url。因此,我必须将Javascript $page.props.csrf_令牌未定义(inertiajs),javascript,laravel,vue.js,laravel-8,inertiajs,Javascript,Laravel,Vue.js,Laravel 8,Inertiajs,我想将用户注销到非惯性url。因此,我必须将csrf令牌传递给具有post方法的表单 <!-- Authentication --> <form method="POST" :action="route('logout')" > <input type="hidden" name="_token" :value="$page.props.csrf_to
csrf令牌
传递给具有post方法的表单
<!-- Authentication -->
<form
method="POST"
:action="route('logout')"
>
<input type="hidden" name="_token" :value="$page.props.csrf_token">
<jet-dropdown-link
colors="text-red-700 focus:bg-gray-200 hover:bg-gray-200"
as="button"
>
logout
</jet-dropdown-link>
</form>
注销
但它给了我一个419页过期的响应
当我console.log(“this.$page.props.csrf_token”)
时,它会显示未定义的
我该怎么办?您需要在“下添加@csrf您需要在“下添加@csrf最简单的方法是使用csrf\u字段
:
<form>
{{ @csrf_field() }}
<!-- other fields -->
</form>
{{@csrf_field()}}
最简单的方法是使用csrf\u字段
:
<form>
{{ @csrf_field() }}
<!-- other fields -->
</form>
{{@csrf_field()}}
我把它
放在我的应用程序布局的标题上。它是vue.js
模板,而不是blade
templatenice。谢谢但这又如何呢:这是我的错。我没有阅读文档,只是看了看代码并尝试了一下。我的应用程序布局的标题上有
。它是vue.js
模板,不是blade
templatenice。谢谢但这又如何呢:这是我的错。我没有读文档,只是看了看代码并试了一下。