0

我只想在我的评论栏中使用溢出:“换行符”选项这是我的代码

 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

但是当我生成我的pdf时,它看起来像这样 在此处输入图像描述

4

1 回答 1

1

尝试更改columnStyles: { text: { columnWidth: 'auto' } }columnStyles: { comment: { columnWidth: 'auto' } }

于 2017-05-17T14:48:05.880 回答