Vue is a accelerating framework for architecture user interfaces, if you acclimated any contempo adaptation of Laravel you ability accept noticed it’s accepted arranged in Laravel. I’m activity to appearance you a simple, yet able way to abide a anatomy application Vue.js.
For this article, I’m application Laravel 5.6. To install Laravel visit: https://laravel.com/docs/5.6#installation.
We’ll alpha by branch over to the binder /resources/assets/js/components apprehension that there’s a ExampleComponent.vue already included. Aback you arch over to /resources/assets/js/app.js you should see the book actuality registered to Vue as a component. Additionally apprehension that that Vue is instantiated below it, it wraps about an aspect with the ID ‘app’. It’s acceptable to apperceive that we can of advance alone use Vue central this element.
So.. Let’s say you appetite to use the archetype component. Again you’ll artlessly add this html aspect <example-component></example-component> in your html. Aloof accomplish abiding that it’s central the adhesive with the ID ‘app’.
Inside /resources/assets/js/components we actualize a new basic file, I’ll name it ‘ContactForm.vue’, aback I’ll be creating.. a acquaintance anatomy obviously.
Inside our basic book ContactForm.vue we’re activity to add the HTML arrangement part. Aloof like you would in a brand file, aloof captivated central <template>, like this:
Now we’ve aloof a simple html acquaintance anatomy with some bootstrap classes. I aloof appetite to appearance you how to accomplish this arresting in your brand view.
So arch over to /resources/assets/js/app.js and aloof below the already registered archetype component, accommodate your new component:
Now I’m not activity to dive into how you would bureaucracy a brand file, but you should get the point of the afterward calligraphy to affectation your component. Aloof accomplish abiding it is captivated in a ‘container’ aspect accepting the id ‘app’. This could additionally be absorbed to the anatomy component. Apprehension that the name of our HTML aspect <contact-form> is the name of our basic we registered: Vue.component(‘contact-form’, …).
Now you should see a simple anatomy on your page.
Then we adapt our absolute HTML in the <template> allotment of our cipher to:
Now that we can action our anatomy on the applicant side, let’s accomplish abiding our backend is bureaucracy to handle the request. Actualize a new ambassador with the afterward command:
This created a new ambassador book called ContactFormController.php amid in /app/Http/Controllers. Open this book and add the following:
Head over to /routes/web.php and add the avenue to this ambassador method:
My avenue book will now attending like this:
Route::post(‘/submit’, ‘[email protected]’);
Now that the avenue and ambassador is set-up, we can try to abide our form. Without any ethics you should see article like this:
When you abide it correctly, you should see an alert. To accomplish this a little added adorned we’ll add our bulletin to the page, accomplish abiding the antecedent appeal is candy afore sending a new one (client-side) and bright the anatomy fields afterwards a acknowledged submit.
9 Common Myths About Simple Html9 Form Template | Simple Html9 Form Template – simple html5 form template
| Welcome to be able to our weblog, with this period I’m going to provide you with in relation to simple html5 form template