如下更改您的数据模型。
data: () => ({
headers: {
{text: 'class'},
{text: 'school1'},
{text: 'school2'},
{text: 'school3'}
},
items: {
... If you need to keep your items, use computedItems. ...
}
},
computed: {
computedItems () {
... rebuild your items like this ...
return {
{class: 'A', school1: [...], school2: [...], school3: [...]},
{class: 'B', school1: [...], school2: [...], school3: [...]},
{class: 'C', school1: [...], school2: [...], school3: [...]},
}
}
}
然后使用v-slot:item.name
<v-data-table
:headers="headers"
:items="computedItems">
<template v-slot:item.school1="{item}">
<template v-for>
<img src="...">
</template>
</template>
<template v-slot:item.school2="{item}">
<template v-for>
<img src="...">
</template>
</template>
<template v-slot:item.school3="{item}">
<template v-for>
<img src="...">
</template>
</template>
</v-data-table>