Search icon CANCEL
Subscription
0
Cart icon
Your Cart (0 item)
Close icon
You have no products in your basket yet
Save more on your purchases! discount-offer-chevron-icon
Savings automatically calculated. No voucher code required.
Arrow left icon
All Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Newsletter Hub
Free Learning
Arrow right icon
timer SALE ENDS IN
0 Days
:
00 Hours
:
00 Minutes
:
00 Seconds
Arrow up icon
GO TO TOP
Vue.js 2 Design Patterns and Best Practices

You're reading from   Vue.js 2 Design Patterns and Best Practices Build enterprise-ready, modular Vue.js applications with Vuex and Nuxt

Arrow left icon
Product type Paperback
Published in Mar 2018
Publisher Packt
ISBN-13 9781788839792
Length 344 pages
Edition 1st Edition
Languages
Tools
Arrow right icon
Author (1):
Arrow left icon
Paul Halliday Paul Halliday
Author Profile Icon Paul Halliday
Paul Halliday
Arrow right icon
View More author details
Toc

Model


One of the most common requirements for any business application is text input. Vue assists us with this need with the v-model directive. It allows us to create reactive two-way data bindings on form input events, making working with forms easily. It's a welcome abstraction over what would otherwise be a tedious way to get form values and input events. To explore this, we can create a new Vue project:

# Create a new Vue project
$ vue init webpack-simple vue-model

# Navigate to directory
$ cd vue-model

# Install dependencies
$ npm install

# Run application
$ npm run dev

We can head over to our root App.vue file and remove everything from the template and instead add a new div that encompasses a label and form input:

<template>
 <div id="app">
  <label>Name:</label>
  <input type="text">
 </div>
</template>

This gives us the ability to add text to our input element, that is, prompting the user to input their name. I'd like to capture this value...

lock icon The rest of the chapter is locked
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at £13.99/month. Cancel anytime
Visually different images