我的表中有三列,但是仅当登录的用户是具有管理员配置文件的用户时,我才想显示第三列。
<b-table id="my-table" hover striped small outlined :items="values" :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"> Show</i>
</b-button>
</template>
</b-table>
fields: [
{ key: 'from', label: 'From', sortable: true },
{ key: 'to', label: 'To', sortable: true },
{ key: 'readTo', label: 'Lida', sortable: true,
formatter: value => value ? 'Yes' : 'No' },
]
仅当用户是管理员时,才会显示“ readTo”列。