To gather data on the web, we use HTML form inputs. In Vue, it's possible to use a two-way data binding method, where the value of the input on the Document Object Model (DOM) is passed to the JavaScript – or vice versa.
This makes the web form more dynamic, giving you the possibility to manage, format, and validate the data before saving or sending the data back to the server.
Getting ready
The prerequisite for this recipe is Node.js 12+.
The Node.js global objects that are required for this recipe are as follows:
- @vue/cli
- @vue/cli-service-global
To start our component, we can create our Vue project with the Vue CLI, as we learned in the Creating your first project with the Vue CLI recipe, or use the project from the Creating the hello world component recipe.
How to do it...
Follow these steps to create an input form with a two-way data binding:
- Let's create a new file called TaskInput.vue in the src/components...