0👍
If you bind the value of the input (using v-model
) to a value in your inputs
array, it should keep your values – even when adding a new input.
let inputs = [];
addInput() {
this.inputs.push({value: ""});
}
<button @click.prevent='addInput'>Add input</button>
<input type='text' value='Default Input'>
<div v-for="(input, index) in inputs" v-bind:key="index">
<input v-model="input.value" type='text'>
</div>
Source:stackexchange.com