I would just make it an array instead of objects
<div v-show="type == 'dropdown'" class="grid gap-4 md:grid-cols-5 items-center">
<template v-for="input, index in inputs" :key="index">
<div class="col-span-2">
<input v-model="value.key" type="text"
class="block p-2 w-full text-gray-700 bg-gray-50 rounded-sm
border border-gray-300" placeholder="Input key"
/>
</div>
<div class="col-span-2">
<input v-model="value.input_value" type="text"
class="block p-2 w-full text-gray-700 bg-gray-50
rounded-sm border border-gray-300" placeholder="Input value"
/>
</div>
<div class="col-span-1">
<fa icon="square-plus"
class="w-6 h-6 text-green-500 cursor-pointer"
@click="add"
/>
<fa v-show="index != 0" icon="square-minus"
class="w-6 h-6 px-2 text-red-500 cursor-pointer"
@click="remove(index)"
/>
</div>
</template>
</div>
export default {
name: "App",
data() {
return {
inputs: [{key: "", value: ""}]
}
},
add() {
this.inputs.push({key: "", value: ""})
},
remove(index) {
this.inputs.splice(index, 1)
},
}