I have a button to create a new component 'AddressField' in each click. Inside this component I have a input that a I need to store the data inside the input;
Here is the button to activate the logic to create a new component
<div class="col-3 p-1">
<button
type="button"
class="btn btn-success col-12"
@click="addAddressField">Calculate
</button>
</div>
Reusable component that is created in each click on the button above
<ul class="p-0 m-0">
<address-field
v-for="(addressfield) in AddressFieldObject"
:key="addressfield.id"
:title="addressfield.title"
v-model="?"
></address-field>
</ul>
Function to add a component
addAddressField() {
this.AddressFieldObject.push({
id: 'id' + this.nextAddressFieldID++,
title: 'title' + this.nextAddressFieldTitle++
})
this.newAddressField = ''
}
Is there anyway to create a name for v-model dynamically? For example:
- 1st click / component with v-model name 'nameModel01'
- 2nd click / component with v-model name 'nameModel02'
- 3rd click / component with v-model name 'nameModel03'
In the end, my objective is to store all the input inside a array or a object, just like:
- array = [nameModel01, nameModel02, nameModel03]