【问题标题】:Why these vuetify data tables slot isn't working?为什么这些 vuetify 数据表插槽不起作用?
【发布时间】:2020-10-14 00:43:47
【问题描述】:

我正在使用 vuetify 数据表

<v-data-table
                :headers="fields"
                :items="items"
                :search="search"
                :mobile-breakpoint="NaN"
                fixed-header
                :loading="isBusy"
            >
                <template v-slot:item="{item,headers}">
                    <tr>
                        <td
                            v-for="(header, index) in headers"
                            :key="index"
                        >{{ header.formatFn(item[header.value]) }}</td>
                    </tr>
                </template>
                <template v-slot:item.userid="{ item }">Abc{{item}}</template>
                <v-alert
                    slot="no-results"
                    :value="true"
                    color="error"
                    icon="warning"
                >Your search for "{{ search }}" found no results.</v-alert>

                <template slot="no-data">No Data Exists!</template>
            </v-data-table>

以下插槽 template v-slot:item.userid="{ item }"&gt;Abc{{item}}&lt;/template&gt; 因任何我无法弄清楚的原因而无法工作

我的字段数组有一个字段“用户 ID”。

【问题讨论】:

  • 请显示数据语法。

标签: vue.js vuetify.js


【解决方案1】:

好吧,我找到了解决方法

<tr>
                        <td v-for="(header, index) in headers" :key="index">
                            <span
                                v-if="header.value != 'userid'"
                            >{{ header.formatFn(item[header.value]) }}</span>
                            <span v-else-if="header.value == 'userid'">
                                // do your work
                            </span>
                            <span v-else>{{ header.formatFn(item[header.value]) }}</span>
                        </td>
                    </tr>

【讨论】:

    猜你喜欢
    • 2021-05-12
    • 1970-01-01
    • 2019-07-14
    • 1970-01-01
    • 2018-06-19
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多