I have an object that is a list of arrays...
..this is a data declared in vue js from a prop:
data: function(){
return{
listaSelezionati:this.selezionati
}
}
..which is rendered on a v-for
<div class="row" style="margin-bottom:20px;" v-for="(selezionato,index) in listaSelezionati">
..inside this for loop there is a button who calls a function
<div class="remove pull-right" v-on:click="rimuovi(index)"></div>
..with this function I want to splice the sub array of object "listaSelezionati" using "index", but I'm not sure how to do it..
here what I have tried:
methods:{
rimuovi : function(index){
alert(index);
return{
this.listaSelezionati[index][0].splice(index,1)
}
}
}
but it does nothing, anyone have something to suggest?
edit1
I want to know if return{this.listaSelezionati
should be a right approach to edit a component data
If you want to remove an entire sub array by index all you need to do is this:
methods:{
rimuovi : function(index){
this.listaSelezionati.splice(index,1)
}
}
There is no need to return a value; splice updates the array it is called on.