【发布时间】:2020-08-20 01:04:35
【问题描述】:
我正在使用 v-data-table (Vuetify 2.x) 并希望执行以下操作。
- 固定表格总行
- 让总数始终可见
- 调整总行的宽度与标题相同
我尝试对上述项目进行编码,但没有成功。
对于#3,我编码使用v-slot:footer,但我无法调整总行数。
这是代码。
<div id="app">
<v-app>
<v-data-table
:headers="headers"
:items="desserts"
:sort-by="['calories', 'fat']"
:sort-desc="[false, true]"
multi-sort
class="elevation-1"
:height="300"
>
<template v-slot:footer>
<tr>
<td style="font-weight:bold">total</td>
<td style="font-weight:bold">{{ total.calories }}</td>
<td style="font-weight:bold">{{ total.fat }}</td>
</tr>
</template>
</v-data-table>
</v-app>
</div>
new Vue({
el: '#app',
vuetify: new Vuetify(),
data () {
return {
headers: [
{
text: 'Dessert (100g serving)',
align: 'start',
sortable: false,
value: 'name',
},
{ text: 'Calories', value: 'calories' },
{ text: 'Fat (g)', value: 'fat' },
],
desserts: [
{
name: 'Frozen Yogurt',
calories: 200,
fat: 6.0,
},
{
name: 'Ice cream sandwich',
calories: 200,
fat: 9.0,
},
{
name: 'Eclair',
calories: 300,
fat: 16.0,
},
{
name: 'Cupcake',
calories: 300,
fat: 3.7,
},
{
name: 'Gingerbread',
calories: 400,
fat: 16.0,
},
{
name: 'Jelly bean',
calories: 400,
fat: 0.0,
},
{
name: 'Lollipop',
calories: 400,
fat: 0.2,
},
{
name: 'Honeycomb',
calories: 400,
fat: 3.2,
},
{
name: 'Donut',
calories: 500,
fat: 25.0,
},
{
name: 'KitKat',
calories: 500,
fat: 26.0,
},
],
total: {
calories: 3600,
fat: 105.1,
},
}
},
})
https://codepen.io/UKanamo/pen/GRpyOEP
当我使用<template v-slot:body.append> 时,我无法使总数始终可见(#2)。
如何对以上项目进行编码?
【问题讨论】:
-
请将代码添加到问题本身而不是 codepen
-
感谢您的回复。我添加了代码。
标签: vuejs2 vuetify.js