i am new to vue js, i have one "iban" entry that I want to do and when "add iban" button is clicked, first entry "delete" range should be added and when I want to delete it starts from above, I think I made a mistake. Thanks already for your help.
<template>
<div class="col-12" v-for="(section, index) in sections">
<div class="mb-1 row">
<div class="col-sm-3">
<label class="col-form-label" for="iban"><span><i data-feather='file-text'></i></span>IBAN NUMBER</label>
</div>
<div class="col-sm-6">
<input type="text" class="form-control" id="iban" v-model="section.item">
</div>
</div>
<div class="mb-1 row" v-for="(addition, index) in section.additionals">
<div class="col-sm-3">
<label class="col-form-label" for="iban"><span><i data-feather='file-text'></i></span>IBAN NUMBER</label>
</div>
<div class="col-sm-6">
<input type="text" class="form-control" placeholder="Item" v-model="addition.item">
<span class="float-right" style="cursor:pointer" @click="removeItem(index)">X</span>
</div>
</div>
<button class="btn btn-success mt-5 mb-5" @click="addNewItem(index)">New Iban</button>
</div>
</template>
<script>
export default {
data() {
return {
data: {
iban: "",
},
sections: [
{
item: '',
additionals: []
}
]
}
},
methods: {
addNewItem(id) {
this.sections[id].additionals.push({
item: ''
})
},
removeItem(index){
this.sections[index].additionals.splice(index,1)
},
},
}
</script>
