v-simple-table
component is a simple wrapper component around the <table>
element. Inside the component you can use all the regular table elements such as <thead>
, <tbody>
, <tr>
, etc. See documentation. <v-simple-table fixed-header height="300px">
<template v-slot:default>
<thead>
<tr>
<th class="text-left">Name</th>
<th class="text-left">Calories</th>
</tr>
</thead>
<tbody>
<tr v-for="item in desserts" :key="item.name">
<td>{{ item.name }}</td>
<td>{{ item.calories }}</td>
</tr>
</tbody>
</template>
</v-simple-table>
export default {
data () {
return {
desserts: [
{
name: 'Frozen Yogurt',
calories: 159,
},
{
name: 'Ice cream sandwich',
calories: 237,
},
{
name: 'Eclair',
calories: 262,
},
{
name: 'Cupcake',
calories: 305,
},
{
name: 'Gingerbread',
calories: 356,
},
{
name: 'Jelly bean',
calories: 375,
},
{
name: 'Lollipop',
calories: 392,
},
{
name: 'Honeycomb',
calories: 408,
},
{
name: 'Donut',
calories: 452,
},
{
name: 'KitKat',
calories: 518,
},
],
}
},
}
Use the fixed-header
prop together with the height
prop to fix the header to the top of the table.
Name | Calories |
---|---|
Frozen Yogurt | 159 |
Ice cream sandwich | 237 |
Eclair | 262 |
Cupcake | 305 |
Gingerbread | 356 |
Jelly bean | 375 |
Lollipop | 392 |
Honeycomb | 408 |
Donut | 452 |
KitKat | 518 |
<v-simple-table dense>
<template v-slot:default>
<thead>
<tr>
<th class="text-left">Name</th>
<th class="text-left">Calories</th>
</tr>
</thead>
<tbody>
<tr v-for="item in desserts" :key="item.name">
<td>{{ item.name }}</td>
<td>{{ item.calories }}</td>
</tr>
</tbody>
</template>
</v-simple-table>
export default {
data () {
return {
desserts: [
{
name: 'Frozen Yogurt',
calories: 159,
},
{
name: 'Ice cream sandwich',
calories: 237,
},
{
name: 'Eclair',
calories: 262,
},
{
name: 'Cupcake',
calories: 305,
},
{
name: 'Gingerbread',
calories: 356,
},
{
name: 'Jelly bean',
calories: 375,
},
{
name: 'Lollipop',
calories: 392,
},
{
name: 'Honeycomb',
calories: 408,
},
{
name: 'Donut',
calories: 452,
},
{
name: 'KitKat',
calories: 518,
},
],
}
},
}
Name | Calories |
---|---|
Frozen Yogurt | 159 |
Ice cream sandwich | 237 |
Eclair | 262 |
Cupcake | 305 |
Gingerbread | 356 |
Jelly bean | 375 |
Lollipop | 392 |
Honeycomb | 408 |
Donut | 452 |
KitKat | 518 |