vue-ajax-form
v0.3.2
Published
A Vue2 component for creating AJAX forms.
Downloads
7
Readme
vue-ajax-form
A Vue2 component for creating AJAX forms.
Installation
via npm
npm install vue-ajax-form --save
via yarn
yarn add vue-ajax-form
import AjaxForm from 'vue-ajax-form'
Vue.component('AjaxForm', AjaxForm)
Or use a CDN
<script src="https://unpkg.com/vue-ajax-form"></script>
Usage
Use it like an HTML form.
<ajax-form action="/users" method="post">
<input type="email" name="email" placeholder="Email address">
<input type="password" name="password" placeholder="Password">
<button type="submit">Submit</button>
</ajax-form>
Props
| Property | Type | Default | Description | Required? | |----------|------|---------|-------------|-----------| | axios | AxiosInstance | The static Axios instance | The axios instance to use for the requests. | No | | action | string | # | The form action | No | | method | string | POST | The form method | No | | data | Object | {} | Additional data to merge into the request | No |
Events
| Event | Description | $event | |----------|------|---------| | before | Emitted before the requests submits. | { axios, action, method, data } | | success | Emitted after a 2xx response | Axios response object | | error | Emitted after a 4xx response | Axios response object | | complete | Emitted after the success or error event | |