【发布时间】:2020-07-06 11:40:38
【问题描述】:
基于这个How to render custom data in Bootstrap-Vue Table component?我创建了这个代码:
assignDocuments(id) {
const documents = this.$store.state.documentList.filter(e => e.user.idUser === id);
console.log(documents);
let i;
for(i=0; i < documents.length;i++) {
return documents[i] ? `${documents[i].filename}` : 'loading...';
}
}
但它不像我需要的那样工作......我需要显示所有对象的名称(文件名)(在这种情况下,我在 documents中有 2 个对象> 数组)在数组中,但现在 b-table 中只显示第一个对象的名称。
编辑:
B表代码:
<b-table ref="table" small striped hover :items="$store.state.userList" :fields="fields" head-variant="dark">
<template v-slot:cell(indexNumber)="row">
{{ row.item.indexNumber}}
</template>
<template v-slot:cell(name)="row">
{{ row.item.name}}
</template>
<template v-slot:cell(surname)="row">
{{ row.item.surname}}
</template>
<template v-slot:cell(specialization.specName)="row">
{{ row.item.specialization.specName}}
</template>
<template v-slot:cell(yearbook)="row">
{{ row.item.yearBook.startYear }}<b>/</b>{{ row.item.yearBook.endYear }}
</template>
<template v-slot:cell(details)="row">
<b-button size="sm" @click="row.toggleDetails" class="mr-2">
{{row.detailsShowing ? 'Ukryj' : 'Pokaż'}} Szczegóły
</b-button>
</template>
</b-table>
字段:
fields:[
{
key: 'indexNumber',
label: 'Numer indeksu'
},
{
key: 'name',
label: 'Imię'
},
{
key: 'surname',
label: 'Nazwisko',
},
{
key: 'specialization.specName',
label: 'Kierunek',
},
{
key: 'yearBook',
label: 'Rocznik',
},
{
key: 'idUser',
label: 'Documents',
formatter: 'assignDocuments'
},
{
key: 'details',
label: 'Szczegóły',
},
],
【问题讨论】:
-
如果您能发布相关的 HTML 代码和任何其他相关的 JS 将会很有帮助
标签: vue.js