How to refer laravel csrf field inside a vue template

Viewed 24482

I have a vue template that contains a form:

<form id="logout-form" :action="href" method="POST" style="display: none;">
        {{ csrf_field() }}
</form>

In laravel, forms must have a csrf_field() defined. But within a vue component, the statement {{ csrf_field() }} means that I have a method named csrf_field in my vue instance and I am calling it.

How do I add csrf_field under this circumstance?

4 Answers

You can use this package: npm install vue-laravel-csrf

Usage: <form v-csrf-token>

Related