<template>
<div class="container-fluid" id="searchResult">
<div class="row">
<div class="col s12">
<div class="card-panel grey lighten-5 z-depth-1">
<table class="highlight">
<tbody>
<tr v-for="(val, key, index) in objSearch">
<td>{{ val.name }}</td>
<td>{{ val.lastname }}</td>
<td>
<a class="waves-effect waves-light btn>Выбрать</a>
</td>
</tr>
</tbody>
</table>
</div>
</div>
</div>
</div>
</template>
<script>
export default {
data() {
return {
objSearch: {
0: {
name: 'Сергей',
lastname: 'Иванович',
},
1: {
name: 'Андрей',
lastname: 'Петрович',
}
},
}
}
}
</script>
data: () => ({
selected: null,
...
}),
<tr v-for="(n, i) in (selected || objSearch)">
@click="selected = selected ? null : { [i]: n }"
.hidden {
visibility: hidden;
}
<tr
v-for="(n, i) in objSearch"
:class="{ hidden: selected !== null && selected !== i }"
>
@click="selected = selected === null ? i : null"
<tr v-for="(val, key, index) in objSearch | filterBy current">
<td>{{ val.name }}</td>
<td>{{ val.lastname }}</td>
<td><a class="waves-effect waves-light btn" @click="Choose(val)">Выбрать</a></td>
</tr>
{
data: function(){
render: {
current: '',
}
}
...
methods: {
Choose: function(val){
this.current = val;
}
}
...
}
<tr v-for="(val, key, index) in objSearch | filterBy current in 'id'">
<td>{{ val.name }}</td>
<td>{{ val.lastname }}</td>
<td><a class="waves-effect waves-light btn" @click="Choose(val)">Выбрать</a></td>
</tr>