我使用jsPDF和autoTable已经有一段时间了,现在正在尝试更新到这两个版本的最新版本;jsPDF 2.0.0和autoTable 3.5.9都是几天前发布的。
jsPDF本身运行良好,但在尝试使用autoTable时出现"doc.autoTable不是一个函数“的错误。
下面是一个非常简单的例子:
<script src="https://unpkg.com/jspdf"></script>
<script src="https://unpkg.com/jspdf-autotable"></script>
<script>
const doc = new jspdf.jsPDF();
doc.autoTable({
head: [['Name', 'Email', 'Country']],
body: [
['David', 'david@example.com', 'Sweden'],
['Castille', 'castille@example.com', 'Spain']
]
});
doc.save('table.pdf');
</script>您可以看到它的实际效果(也可以不看!)在https://jsfiddle.net/r8dah0m7/。
有没有人使用下载的/ CDN dist文件让autoTable 3.5.9与jsPDF 2.0.0一起工作,如果是,我错过了什么?
发布于 2020-08-22 07:56:35
请尝试以下操作
autoTable(doc, {
head: [['Name', 'Email', 'Country']],
body: [
['David', 'david@example.com', 'Sweden'],
['Castille', 'castille@example.com', 'Spain']
]
});3.5.9的文档尚未更新。
https://stackoverflow.com/questions/63411601
复制相似问题