so I need to have a form input create whenever the user adds a value to the previous input. I've found some great questions about how to create dynamic forms and also how to watch form inputs to call a function but I don't know how to combine the two and make them work together.
new Vue({
el: '#form',
data: {
items: [],
},
methods: {
addItem() {
this.items.push({
value: ''
});
}
}
})
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/vue.js"></script>
<div id="form">
<input v-for="item in items" v-model="item.value">
<button @click="addItem">add</button> {{items}}
</div>
So currently I can make this work by adding a button to add the new input but the input doesn't show until after you click the button. I tried v-for="item in items + 1" but that cause crazy unexpected results and after I thought about it I realized why that couldn't work. I would really like to have an input box on load and if the user adds any value to that box a new one will be created.