我正在使用jsPDF & autotable在我的DOM树中生成一个表格。我的项目是基于Wordpress的,我通过CDN注册并加入了()两个库。
但是当执行我的pdf生成代码时,它失败了,错误如下:
Uncaught TypeError: t.getDocument().getFillColor is not a function
f https://cdnjs.cloudflare.com/ajax/libs/jspdf-autotable/3.5.23/jspdf.plugin.autotable.min.js:10
c https://cdnjs.cloudflare.com/ajax/libs/jspdf-autotable/3.5.23/jspdf.plugin.autotable.min.js:10
drawTable https://cdnjs.cloudflare.com/ajax/libs/jspdf-autotable/3.5.23/jspdf.plugin.autotable.min.js:10
drawTable https://cdnjs.cloudflare.com/ajax/libs/jspdf-autotable/3.5.23/jspdf.plugin.autotable.min.js:10
autoTable https://cdnjs.cloudflare.com/ajax/libs/jspdf-autotable/3.5.23/jspdf.plugin.autotable.min.js:10因为我找不到任何类似的问题,也不能自己解决它,所以我想分享我的问题。
const doc = new jsPDF({
orientation: "landscape",
unit: "mm",
format: [300, 260]
});
doc.text(25, 25, "Header");
doc.addPage();
doc.autoTable({ html: '#my-table' });
doc.save(pdfName);<table id="my-table" class="table table-bordered table-custom">
<thead id="test-thead">
<tr>
<td>Col 1</td>
<td>Col 2</td>
</tr>
</thead>
<tbody id="test-tbody">
<tr>
<td>Test 1</td>
<td>Test 2</td>
</tr>
</tbody>
</table>发布于 2021-11-17 15:58:39
我通过调用一个旧版本的autotable.js成功地让它工作起来
<script src="https://unpkg.com/jspdf-autotable@3.5.22/dist/jspdf.plugin.autotable.js"></script>似乎是在最新的版本3.5.23中,它缺少一个用于getFillColor的方法。
https://stackoverflow.com/questions/69901224
复制相似问题