vue-form-helper
v1.0.0
Published
A small package for handling form operations with Vue.js that easily integrate into Laravel projects. This is a slightly modified version of Jeffrey Way's lesson on Object Oriented Forms in Vue.js with more updates to come.
Downloads
2
Readme
Vue-Form-Helper
Setup
/**
* Vue is a modern JavaScript library for building interactive web interfaces
* using reactive data binding and reusable components. Vue's API is clean
* and simple, leaving you to focus on building your next great project.
*/
window.Vue = require('vue/dist/vue.js');
/**
* We'll load the axios HTTP library which allows us to easily issue requests
* to our Laravel back-end. This library automatically handles sending the
* CSRF token as a header based on the value of the "XSRF" token cookie.
*/
window.axios = require('axios');
window.axios.defaults.headers.common = {
'X-CSRF-TOKEN': window.Laravel.csrfToken,
'X-Requested-With': 'XMLHttpRequest'
};
Vue.prototype.$http = axios;
Example Usage
new Vue({
el: '#app',
data: {
form: new Form({
name: '',
description: ''
})
},
methods: {
onSubmit() {
this.form.post('/projects')
.then(response => alert('Wahoo!'));
}
}
});