In this lesson, we will learn how to iterate over an array in a Vue.js template using the
v-for property. We can add to and remove from that list using
Thank you for the introduction.
For better semantics and accessibility I think it's better to always use a
<form> when collecting user input. This way the form shows up in the accessibility tree. By hooking up to the submit event, a new item is added when the button is clicked, or the user presses enter in the input field, or any other way the form could be submitted. Finally, adding a label to an input field helps clarifying what input is expected. So the template would become something like this:
<form v-on:submit.prevent="addItem"> <label for="newItem">New dinosaur</label> <input id="newItem"> <button>Add</button> </form>