【问题标题】:Vuetify v-data-table render multiple v-edit-dialogVuetify v-data-table 渲染多个 v-edit-dialog
【发布时间】:2021-11-22 00:24:03
【问题描述】:

文档有 example 用于将内联编辑对话框添加到列。我正在尝试将其添加到每一列。

  1. 当然是复制粘贴。
  2. 渲染行 - 但它会删除 v-data-table 行的默认功能(即:可排序) --> 我不选择
  3. 将 v-for 与 v-slot 一起使用 - 但有错误 demo

<template v-for="header in headers" v-slot:item[header.value]="propsAPI">
  <v-edit-dialog
    :return-value.sync="propsAPI.item[header.value]"
    @save="save"
    @cancel="cancel"
    @open="open"
    @close="close"
    :key="header.value"
  >
    {{ propsAPI.item[header.value] }}
    <template v-slot:input>
      <v-text-field
        v-model="propsAPI.item[header.value]"
        :rules="[max25chars]"
        label="Edit"
        single-line
        counter
      />
    </template>
  </v-edit-dialog>
</template>

任何建议

【问题讨论】:

    标签: vue.js vuetify.js


    【解决方案1】:

    你可以替换

    <template v-for="header in headers" v-slot:item[header.value]="propsAPI">
    

    <template v-for="header in headers" v-slot:[`item.${header.value}`]="propsAPI">
    

    这应该为每一列重新定义槽。

    【讨论】:

    • 使用${} 是不是很坑爹?因为我只在字符串中使用它
    • @TanNguyen,不,你只需要动态定义你的插槽名称,字符串 concat 正好适合这个。你也可以改写v-slot:['item.' + header.value]
    猜你喜欢
    • 1970-01-01
    • 2021-01-24
    • 2020-02-26
    • 2019-11-10
    • 2020-12-13
    • 2019-11-19
    • 2021-05-12
    • 2021-05-30
    • 1970-01-01
    相关资源
    最近更新 更多