Tom*_*Tom 11 javascript datatable vue.js vuetify.js
我正在使用VuetifyJS数据表,我需要将每个标题单元格的条目尽可能地彼此移动.我试图为每个标题添加一个宽度,但这不起作用 - 似乎有一个预定义的宽度,不能低于此.
这是一个CodePen示例:
Run Code Online (Sandbox Code Playgroud)https://codepen.io/anon/pen/ejEpKZ?&editors=101
<div id="app">
<v-app id="inspire">
<v-data-table
:headers="headers"
:items="desserts"
class="elevation-1"
>
<template slot="headerCell" slot-scope="props">
<v-tooltip bottom>
<span slot="activator">
{{ props.header.text }}
</span>
<span>
{{ props.header.text }}
</span>
</v-tooltip>
</template>
<template slot="items" slot-scope="props">
<td>{{ props.item.name }}</td>
<td class="text-xs-right">{{ props.item.calories }}</td>
<td class="text-xs-right">{{ props.item.fat }}</td>
<td class="text-xs-right">{{ props.item.carbs }}</td>
<td class="text-xs-right">{{ props.item.protein }}</td>
<td class="text-xs-right">{{ props.item.iron }}</td>
</template>
</v-data-table>
</v-app>
</div>
Run Code Online (Sandbox Code Playgroud)
如何让他们靠近在一起?
只需在标题中添加 (width,align)
<v-data-table
:headers="headers"
:items="desserts"
class="elevation-1"
>
</v-data-table>
Run Code Online (Sandbox Code Playgroud)
标题看起来像
header:[ {
text: 'Dessert ',
align: 'center',<------------to align left/center/right/
value: 'name',
width: "1%"//<-------------------asign width/
},
]
Run Code Online (Sandbox Code Playgroud)
Vuetify 标头选项:
{
text: string
value: string
align: 'left' | 'center' | 'right'
sortable: boolean
class: string[] | string
width: string
}
Run Code Online (Sandbox Code Playgroud)
您可以使用标题设置宽度,如下所示
headers: [
{ text: 'Dessert (100g serving)', value: 'name', width: '20%'},
{ text: 'Calories', value: 'calories', width: '50%' },
{ text: 'Fat (g)', value: 'fat' },
{ text: 'Carbs (g)', value: 'carbs', width: '200px' },
],
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
18458 次 |
| 最近记录: |