【问题标题】:Why Vuetify tables shows inconsistent cells width?为什么 Vuetify 表格显示不一致的单元格宽度?
【发布时间】:2020-02-05 06:19:40
【问题描述】:

在 Vue 中,我在同一个组件的模板中创建了多个表。这些表都有相同的 html 模板,除了它们使用不同的data () 属性。不知何故,它们之间的列宽不一致。

<template>
    <v-container>
        <h2>Security</h2>
        <hr>
        <v-simple-table>
            <template v-slot:default>
                <tbody>
                <tr v-for="(a, index) in user_info.security_titles"
                    :key="a">
                    <td><strong>{{ a }}</strong></td>
                    <td v-show="user_info.security_data">{{user_info.security_data[index]}}</td>
                </tr>
                </tbody>
            </template>
        </v-simple-table>
        <br>
        <h2>Connection</h2>
        <hr>
        <v-simple-table>
            <template v-slot:default>
                <tbody>
                <tr v-for="(b, index) in user_info.connection_titles"
                    :key="b">
                    <td> <strong>{{ b }}</strong> </td>
                    <td v-show="user_info.connection_data">{{user_info.connection_data[index]}}</td>
                </tr>
                </tbody>
            </template>
        </v-simple-table>
        <br>
        <h2>Language</h2>
        <hr>
        <v-simple-table>
            <template v-slot:default>
                <tbody>
                <tr v-for="(c, index) in user_info.language_titles"
                    :key="c">
                    <td> <strong>{{ c }}</strong> </td>
                    <td v-show="user_info.language_data">{{user_info.language_data[index]}}</td>
                </tr>
                </tbody>
            </template>
        </v-simple-table>
    </v-container>
</template>

我用过任何风格

【问题讨论】:

    标签: html vue.js vue-component vuetify.js


    【解决方案1】:

    表格总是试图以最好的方式适应内容,因此如果您的列中包含一行长文本,则该列将占用更多空间。

    您可以在标题中使用 width 属性来获得固定宽度,如 in the docs 所示

    {
      text: string
      value: string
      align?: 'start' | 'center' | 'end'
      sortable?: boolean
      filterable?: boolean
      divider?: boolean
      class?: string | string[]
      width?: string | number
      filter?: (value: any, search: string, item: any) => boolean
      sort?: (a: any, b: any) => number
    }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2021-08-07
      • 2014-06-25
      • 2020-11-22
      • 2019-06-16
      • 2011-10-07
      • 2014-08-11
      • 1970-01-01
      • 2012-12-17
      相关资源
      最近更新 更多