首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >如何在vue-good-table中显示类型为array的字段的下拉列表

如何在vue-good-table中显示类型为array的字段的下拉列表
EN

Stack Overflow用户
提问于 2021-05-13 01:16:40
回答 1查看 48关注 0票数 0

在vue-good-table中有没有一种方法来显示dropdown --数据类型是array?

下面给出的行数:

代码语言:javascript
复制
[
  {
    name: "test",
    fqdn: "test",
    SystemCustodianId: "test",
    SystemCustodianName: "test",
    freqency: ["Weekly", "Monthly", "Bi-Weekly", "Twice Monthly"],
  },
  {
    name: "test",
    fqdn: "test",
    SystemCustodianId: "test",
    SystemCustodianName: "test",
    freqency: ["Weekly", "Monthly", "Bi-Weekly", "Twice Monthly"],
  },
]

下面给出的列:

代码语言:javascript
复制
[ 
      {
          label: "NAME",
          field: "name",
      },
      {
          label: "Platform Name",
          field: "fqdn",
      },
      {
          label: "System Custodian",
          field: "SystemCustodianName",
      },
      {
          label: "System Custodian ID",
          field: "SystemCustodianId",
      },
      {
          label: "Frequency",
          field: "frequency",
      }
    ]
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2021-05-13 01:48:40

您需要使用table-row插槽。以下是代码

代码语言:javascript
复制
<template>
  <div id="app">
    <vue-good-table :columns="columns" :rows="rows">
      <template slot="table-row" slot-scope="props">
        <span v-if="props.column.field == 'freqency'">
          <span style="font-weight: bold; color: blue">
            <select>
              <option
                v-for="(val, index) in props.formattedRow.freqency"
                :value="val"
                :key="props.column.field + ' ' + index"
              >
                {{ val }}
              </option>
            </select>
            {{ props.row.age }}
          </span>
        </span>
        <span v-else>
          {{ props.formattedRow[props.column.field] }}
        </span>
      </template>
    </vue-good-table>
  </div>
</template>

<script>
export default {
  name: "App",
  data() {
    return {
      columns: [
        {
          label: "NAME",
          field: "name",
        },
        {
          label: "Platform Name",
          field: "fqdn",
        },
        {
          label: "System Custodian",
          field: "SystemCustodianName",
        },
        {
          label: "System Custodian ID",
          field: "SystemCustodianId",
        },
        {
          label: "Frequency",
          field: "freqency",
        },
      ],
      rows: [
        {
          name: "test",
          fqdn: "test",
          SystemCustodianId: "test",
          SystemCustodianName: "test",
          freqency: ["Weekly", "Monthly", "Bi-Weekly", "Twice Monthly"],
        },
        {
          name: "test",
          fqdn: "test",
          SystemCustodianId: "test",
          SystemCustodianName: "test",
          freqency: ["Weekly", "Monthly", "Bi-Weekly", "Twice Monthly"],
        },
      ],
    };
  },
};
</script>

工作sandbox

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/67508229

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档