fix(component): 解决导出excel数据某一项为null时计算宽度报错 (#2338)

This commit is contained in:
destiny 2022-11-09 09:58:30 +08:00 committed by GitHub
parent fc2e2c8789
commit d16f6f8e44
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 2 additions and 2 deletions

View File

@ -17,8 +17,8 @@ function setColumnWidth(data, worksheet, min = 3) {
data.forEach((item) => {
Object.keys(item).forEach((key) => {
const cur = item[key];
const length = cur.length;
obj[key] = Math.max(min, length);
const length = cur?.length ?? min;
obj[key] = Math.max(length, obj[key] ?? min);
});
});
Object.keys(obj).forEach((key) => {