项目中遇到,表格字段显示需要判断, 用到了这些属性,小记一下
template中的写法
<a-table
ref="table"
size="middle"
bordered
rowKey="id"
class="j-table-force-nowrap"
:scroll="{ x: true }"
:columns="columns"
:dataSource="dataSource"
:pagination="ipagination"
:loading="loading"
@change="handleTableChange"
>
<!-- 初步诊断 -->
<template slot="auto_diagnosis" slot-scope="item">
<span>
{{item.diagnosisName?item.diagnosisName:item.otherDiagnosis }}
</span>
</template>
</a-table>
data中这样写:
{
title: '初步诊断',
align: 'center',
slots: { title: 'auto_diagnosis' },
scopedSlots: { customRender: 'auto_diagnosis' },
},
]
就完美结局咯~