const patientColumns = ref title 病人姓名 dataIndex cfXm key cfXm title 性别 dataIndex cfXb key cfXb title 年龄 dataIndex cfAge key cfAge title 身份证 dataIndex cfSfz key cfSfz title 疾病 d
您可以在 patientColumns 中的 dataIndex 属性后面添加一个自定义的渲染函数,用于将性别值转换为相应的文字表示。例如:
const patientColumns = ref([
{
title: '病人姓名',
dataIndex: 'cfXm',
key: 'cfXm'
},
{
title: '性别',
dataIndex: 'cfXb',
key: 'cfXb',
render: (text) => {
return text === 1 ? '男' : '女';
}
},
{
title: '年龄',
dataIndex: 'cfAge',
key: 'cfAge'
},
{
title: '身份证',
dataIndex: 'cfSfz',
key: 'cfSfz'
},
{
title: '疾病',
dataIndex: 'cfJb',
key: 'cfJb'
},
{
title: '处方数',
dataIndex: 'count',
key: 'count'
},
]);
在上面的代码中,我们为性别列添加了一个渲染函数,根据 text 的值来判断是男还是女,并返回对应的文字表示。
这样,在 <JVxeTable> 组件中展示时,性别列的值会被转换成男女显示
原文地址: http://www.cveoy.top/t/topic/iZMt 著作权归作者所有。请勿转载和采集!