我的表格语法:> var res = doc.autoTableHtmlToJson(document.getElementById(tableID));> doc.autoTable(res.columns, res.data, { styles: {overflow: 'linebreak'> ,columnWidth: [100,80,80,70,80,80,70,70,70,70,60,80,100]}, startY:> 60, bodyStyles: {valign: 'top'}, });解决方案您必须将columnWidth数组转换为如下形式: doc.autoTable({ html: '#table', columnStyles: { 0: {cellWidth: 100}, 1: {cellWidth: 80}, 2: {cellWidth: 80}, // etc }}); 请注意使用columnStyles而不是styles.My table has 13 columns. How can I get different width for each column? Can I give each column width like this?styles: {overflow: 'linebreak' ,columnWidth: [100,80,80,70,80,80,70,70,70,70,60,80,100]},My table Syntax:> var res = doc.autoTableHtmlToJson(document.getElementById(tableID));> doc.autoTable(res.columns, res.data, { styles: {overflow: 'linebreak'> ,columnWidth: [100,80,80,70,80,80,70,70,70,70,60,80,100]}, startY:> 60, bodyStyles: {valign: 'top'}, }); 解决方案 You would have to transform your columnWidth array to look like this:doc.autoTable({ html: '#table', columnStyles: { 0: {cellWidth: 100}, 1: {cellWidth: 80}, 2: {cellWidth: 80}, // etc }});Note the use of columnStyles instead of styles. 这篇关于jspdf autotable中每列的宽度不同?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 上岸,阿里云!
07-22 13:16