我只想在我的评论栏中使用溢出:"换行符" 选项,这是我的代码
var columns = [
{ title: "Date", dataKey: "date" },
{ title: "User", dataKey: "user" },
{ title: "Issue", dataKey: "issue" },
{ title: "Hours", dataKey: "hours" },
{ title: "Comment", dataKey: "comment" }
];
var rows = [];
for (let i = 0; i < this.reports.length; i++) {
var element = {
date: 5,
user: 5,
issue: 3,
hours: 2,
comment:"dsfsudihfusidfhsyudfyhdysuyfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff"
};
rows.push(element);
}
var options = {
overflow: "linebreak"
}
var doc = new jsPDF();
doc.autoTable(columns, rows, {
startY: doc.autoTable.previous.finalY + 15,
margin: { horizontal: 7 },
bodyStyles: { valign: 'top' },
styles: { overflow: 'linebreak', columnWidth: 'wrap' },
columnStyles: { text: { columnWidth: 'auto' } }
});
doc.save('table.pdf');
我从他们的示例文件https://github.com/simonbengtsson/jsPDF-AutoTable/blob/master/examples/examples.js
中复制了此解决方案答案 0 :(得分:1)
尝试将columnStyles: { text: { columnWidth: 'auto' } }
更改为columnStyles: { comment: { columnWidth: 'auto' } }