1👍
✅
You should only need a simple reduce
to flatten the nested item arrays..
methods: {
loadData () {
axios.get('dataapi')
.then((response) => {
this.dataItems = response.data.reduce(function(acc, v) {
return [...acc, ...v.entradas]
},[])
})
},
}
<v-data-table
:headers="headers"
:items="dataItems"
class="elevation-1"
></v-data-table>
0👍
Try this
...
data () {
return {
headers: [
{
text: 'Data',
align: 'start',
sortable: false,
value: 'date',
},
{ text: 'Title', value: 'title', sortable: false },
{ text: 'Amount', value: 'amount', sortable: false },
],
dataItems: [],
}
},
methods: {
loadData () {
axios
.get('dataapi')
.then(response => {
this.dataItems = response.data.map(dataItem => {
const { amount, date, entradas } = dataItem
entradas.map(entrada => {
return {
amount,
date,
...entrada
}
})
})
})
},
}
...
<template>
<v-app id="testdatatable">
<v-data-table
:headers="headers"
:items="dataItems"
class="elevation-1"
></v-data-table>
</v-app>
</template>
Source:stackexchange.com