假设我有一个表,有时有一些数据可能为空,但空数据在表中显示为未定义,而不是显示为未定义.我希望显示"N/A",我如何才能实现共享下面的图像和代码.
在上面的图像中,参考数据下的一些数据显示未定义,因为它是空的,我希望它显示"N/A".我将在下面分享代码.在代码下面有一个"a.Normal Range"变量,该变量保存引用数据.
var col = ["Test Name", "Result", "Unit" , "Reference"];
this.xyz.forEach((a) => {
medicineInfo = this.xyz.find(x => x.id == a.id);
rows.push(['' + a.xyz+' '+ a.xyz+ '', '' + a.xyz+ '', '' + a.xyz,'' + a.xyz]);
});
这就是我打印表格的方式
doc.autoTable({
columnStyles: {
0: { cellWidth: 45 },
1: { cellWidth: 45 },
2: { cellWidth: 45 },
3: { cellWidth: 45 }
},
head: [col],
body: rows,
startY: 100,
theme: 'plain',
tableLineColor: [242, 238, 238],
tableLineWidth: 0.5,
styles: {
font: 'courier',
lineColor: [242, 238, 238],
lineWidth: 0.5
},
});