Reputation: 79
I have inline table from database connection with vueJS. the plan is to make a duplicate of one of the rows. row was successfully duplicated with this.array.push (... ...)
but when I want to remove it in a way this ar.array.splice (index (from row), 1)
the deleted ones are the top or bottom, not the row in the index that was clicked on
code:
public duplicate(){
this.countries.push({
name: this.multipleSelection[0].name,
code: this.multipleSelection[0].code,
currencyId: this.multipleSelection[0].currencyId,
currencyName: this.multipleSelection[0].currencyName,
duplicate: true
})
}
public cancelDuplicate(item, index){
this.countries.splice(index, 1)
console.log(index)
}
Upvotes: 0
Views: 172
Reputation: 111
You can use findIndex to splice arr
this.countries.splice(this.countries.findIndex(e => e === index),1)
Upvotes: 3