【问题标题】:How to dynamically render a list of different datatables如何动态呈现不同数据表的列表
【发布时间】:2019-06-06 15:32:30
【问题描述】:

支持用户创建/删除将在后端持久化的动态数据表的功能。


// statically typed data table
    <v-data-table
        :pagination.sync="pagination"
        :headers="headers"
        :items="items"
        class="elevation-1"
      >
        <template v-slot:items="props">
          <td>{{ props.item.name }}</td>
          <td class="text-xs-right">{{ props.item.column1 }}</td>
          <td class="text-xs-right">{{ props.item.column2 }}</td> 
          <td class="text-xs-right">{{ props.item.column3 }}</td>
          <td class="text-xs-right">{{ props.item.column4 }}</td>
          </td>
        </template>
      </v-data-table>

但是我的情况是:

<template v-for="table in tables">
    //where table will be a new <v-data-table> component with arbitrary rows 
</template>

此外,这些数据表将具有实时更新,因此我必须以某种方式将每个数据表状态与 vuex 链接以增强反应性。

【问题讨论】:

    标签: vue.js dynamic datatables vuetify.js


    【解决方案1】:

    这里是你的第一个步骤的链接,只需结合v-forv-data-table

    https://codepen.io/anon/pen/QRXyBg?editors=1010

    并遍历tables 属性。你可以分享headers。 如果您需要动态/反应性数据,只需从 methods 或其他一些地方更新 tables 属性。

    【讨论】:

    • 感谢您的回复。但是第一部分很容易(迭代表格),第二部分是我真正需要良好反馈的地方。如何将数据填充到从持久源派生的每个数据表中,在我的情况下是 vuex?换句话说,如何将每个表与动态实时数据绑定?
    • 你应该显示一些代码。无效的示例或代码。
    • 顺便说一句。检查 Vuex getter,可能对你有用。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2015-05-02
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多