【发布时间】:2020-09-01 10:34:51
【问题描述】:
我需要对 from 和 to 列应用格式化程序,以便将它们识别为表中显示的值、它们的描述而不是它们的代码。
<b-table id="my-table" hover striped small outlined :items="items" :fields="fields" class="mt-0 mb-0">
<template slot="actions" slot-scope="data">
<b-button variant="info" @click="viewMessage(data.item)" class="mr-2" size="sm">
<i class="fa fa-envelope-open"> View</i>
</b-button>
</template>
</b-table>
items: [
{ date: '01/01/2008', from: '1', to: '2', city: 'Paris' },
{ date: '06/03/2018', from: '3', to: '1', city: 'New York' },
{ date: '05/06/2012', from: '3', to: '2', city: 'Tokyo' },
{ date: '07/08/2019', from: '2', to: '3', city: 'Paris' }
]
fields: [
{ key: 'date', label: 'Date', sortable: true },
{ key: 'from', label: 'From', sortable: true },
{ key: 'to', label: 'To', sortable: true },
{ key: 'city', label: 'City', sortable: true },
}
dataBackend = [
0 = { code: 1, description: 'Joel' },
1 = { code: 2, description: 'Maria' },
2 = { code: 3, description: 'Lucas' }
]
当前:
预期结果:
【问题讨论】:
-
@Dcoder 目前目前正在根据“items”列表通过代码显示“From”和“To”列的值,但是我想根据“dataBackend”列表,以便显示描述而不显示代码。
标签: vue.js bootstrap-vue