Answer the question
In order to leave comments, you need to log in
How to efficiently filter an array within an array?
The question is both about JS and about Vue.
JS first.
There is an array:
[
['name', 'surname', 'age', 'job'],
['Vasya', 'Pupkin', '22', 'banker'],
['Petya', 'Seledkin', '23', 'developer'],
['Vova', 'Putin', '88', 'politician'],
...еще 10к таких же
]
[
['name', 'job'],
['Vasya', 'banker'],
['Petya', 'developer'],
['Vova', 'politician'],
...еще 10к таких же
]
<table>
<tr v-for="(item, i) in parsedCSV" :key="i">
<th v-if="i === 0 || i === 3" v-for="(rowItem, index) in item" :key="index">
{{ rowItem }}
</th>
</tr>
</table>
v-if
use v-for
. What is the best way to do it then?
Answer the question
In order to leave comments, you need to log in
<tr v-for="item in parsedCSV">
<td v-for="i in [ 0, 3 ]">{{ item[i] }}</td>
</tr>
shortItems() {
return this.parsedCSV.map(([ name,,,job ]) => [ name, job ]);
},
<tr v-for="item in shortItems">
<td v-for="el in item">{{ el }}</td>
</tr>
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question