I tried to understand how using closure in my case that summarize data. Perhaps I should use map() or filter() before arrow function or instead of I don't know sure. I read MDN and this article Closures and arrow syntax but all useless. P.S. If my English is terrible - sorry for that. Many thanks for all your assistance.
data(){
return{
tableData: [
{
id: 1,
col1: 10,
col2: 20,
},
{
id: 1,
col1: 20,
col2: 30,
}
]
}
},
computed: {
getSum1(x) {
const findId = this.tableData.find(i => i.id === x);
console.log(findId);
}
},
<div class="table">
<table>
<tr>
<th>Column 1</th>
<th>Column 2</th>
<th>Summary</th>
</tr>
<tr>
<td>{{tableData[0].col1}}</td>
<td>{{tableData[0].col2}}</td>
<td>{{getSum1}}</td>
</tr>
<tr>
<td>{{tableData[1].col1}}</td>
<td>{{tableData[1].col2}}</td>
<td>{{getSum2}}</td>
</tr>
</table>
</div>