Book Image

Building Forms with Vue.js

By : Marina Mosti
Book Image

Building Forms with Vue.js

By: Marina Mosti

Overview of this book

Almost every web application and site out there handles user input in one way or another, from registration forms and log-in handling to registration and landing pages. Building Forms with Vue.js follows a step-by-step approach to help you create an efficient user interface (UI) and seamless user experience (UX) by building quick and easy-to-use forms. You’ll get off to a steady start by setting up the demo project. Next, you’ll get to grips with component composition from creating reusable form components through to implementing the custom input components. To further help you develop a convenient user input experience, the book will show you how to enhance custom inputs with v-mask. As you progress, you’ll get up to speed with using Vuelidate and Vuex to effectively integrate your forms. You’ll learn how to create forms that use global state, reactive instant user input validation and input masking, along with ensuring that they are completely schema-driven and connected to your application’s API. Every chapter builds on the concepts learned in the previous chapter, while also allowing you to skip ahead to the topics you’re most interested in. By the end of this book, you will have gained the skills you need to transform even the simplest form into a crafted user and developer experience with Vue.
Table of Contents (15 chapters)
Title Page

Installing Vue CLI onto our computer

At the time of writing, the Vue CLI has the requirements of Node version 8.9 or above (8.11.0+ is recommended), so we need to make sure you have that set up on your development computer first.

To check if you already have it installed, perform the following steps:

  1. Open up a Terminal (also known as a command line!)
  2. Execute the node -v command

If you get back an output with a version tag, then you have it installed, and you can skip ahead.

If you don't have Node already, head over to the following link in your browser:

You should be presented with a Home screen and two big green download buttons. We will be using the one labeled Current, as shown in the following screenshot: 

So, go ahead and click on the button and follow the installation instructions for your own OS.

Once the installation is complete, verify that everything is working correctly:

  1. Open your Terminal
  2. Execute the node -v command

You should get an output similar to v12.2.0, verifying that the node has correctly been installed to your system.

To actually get Vue CLI installed to our system, however, we still need to make use of a package manager. 

Now, when you installed Node, you actually got a copy of npm installed on your system for free. You can verify this by typing npm -v in your Terminal, and, as before, you will get a version number as output. 

Be aware that the Vue CLI requires Node version 8.9 or above (8.11.0+ recommended) at the time of writing, but make sure you check the following link for the exact version number for the moment you follow this book:

Finally, it is time to actually get things up and running. Fire up your Terminal once again, and run the following command:

> npm install --global @vue/cli

The Terminal will go ahead and download all of the required files onto your computer and set them up in a globally accessible path so you can use this CLI tool anywhere on your computer. Neat, right?

Note the --global flag on this command. What this means is that you're installing this package globally on your computer. In short, this means that you will be able to use the commands from anywhere inside your filesystem, without having to navigate to a specific folder.

For future reference, you can also use the shorthand for --global, which is simply -g.

Once more, let's check that everything was installed properly by running vue --version on the Terminal. You should get back the version number of Vue CLI.

Now that we have our CLI set up, we can start with creating our new project. Let's dive deeper into how to do this in the following section.