|
@ -234,14 +234,14 @@ export async function blobValidate(data) { |
|
|
* 注:prop,title有一个必传 |
|
|
* 注:prop,title有一个必传 |
|
|
*/ |
|
|
*/ |
|
|
export function flexWidth(prop, tableData, title, num = 0) { |
|
|
export function flexWidth(prop, tableData, title, num = 0) { |
|
|
if (tableData.length === 0) { // 表格没数据不做处理
|
|
|
|
|
|
return |
|
|
|
|
|
} |
|
|
|
|
|
let flexWidth = 0// 初始化表格列宽
|
|
|
let flexWidth = 0// 初始化表格列宽
|
|
|
let columnContent = ''// 占位最宽的内容
|
|
|
let columnContent = ''// 占位最宽的内容
|
|
|
const canvas = document.createElement('canvas') |
|
|
const canvas = document.createElement('canvas') |
|
|
const context = canvas.getContext('2d') |
|
|
const context = canvas.getContext('2d') |
|
|
context.font = '14px Microsoft YaHei' |
|
|
context.font = '14px Microsoft YaHei' |
|
|
|
|
|
if (tableData.length === 0) { // 表格没数据不做处理
|
|
|
|
|
|
return context.measureText(title).width + 20 + num + 'px' |
|
|
|
|
|
} |
|
|
// 获取占位最宽的内容
|
|
|
// 获取占位最宽的内容
|
|
|
let index = 0 |
|
|
let index = 0 |
|
|
for (let i = 0; i < tableData.length; i++) { // 循环表格内容,获取表格内容中最长的数据
|
|
|
for (let i = 0; i < tableData.length; i++) { // 循环表格内容,获取表格内容中最长的数据
|
|
|