2
Regardless of which line I try to delete, it always deletes the first:
Returns the following error: Property or method "$index" is not defined on the instance but referenced during render. Make sure to declare reactive data properties in the data option.
<div class="container">
<div id="table">
<table class="table">
<thead>
<tr>
<th>Clubes</th>
<th>Socios</th>
<th style="width: 36px;"></th>
</tr>
</thead>
<tbody id="tbody">
<tr v-for="item in list">
<td>{{item.clube}}</td>
<td>{{item.socio}}</td>
<td>
<a style="cursor: pointer;" v-on:click="removeLine($index)"><i class="glyphicon glyphicon-remove"></i></a>
</td>
</tr>
</tbody>
</table>
</div>
</div>
<script type="text/javascript">
new Vue({
el: '#table',
data: {
list: [{clube: 'Flamengo', socio: 'carl'}, {clube: 'Santos', socio: 'mark'}]
},
methods: {
removeLine(index){
this.list.splice(index, 1);
}
}
});
</script>
Takes the
$index
, exchange foritem
– Denis Rudnei de Souza
Keeps giving exactly the same problem.
– Lucas Caresia
Put the whole code
– Denis Rudnei de Souza
Ready, updated the question.
– Lucas Caresia