我正在使用jspdf-autotable下载pdf文件。我的html文件的表id是myTable。我没有得到pdf文件作为table.pdf.What shoule我改变了我的代码?我的代码在javascript下面
<script language="text/javascript">
<script src="https://cdnjs.cloudflare.com/ajax/libs/jspdf/1.3.2/jspdf.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jspdf-autotable/2.3.2/jspdf.plugin.autotable.js"></script>
<script>
var doc = new jsPDF('p', 'pt');
var elem = document.getElementById("myTable");
var res = doc.autoTableHtmlToJson(elem);
doc.autoTable(res.columns, res.data);
doc.save("table.pdf"); </script>
</script>
答案 0 :(得分:2)
您不能将脚本标记放在脚本标记中。将代码更改为:
<script src="https://cdnjs.cloudflare.com/ajax/libs/jspdf/1.3.2/jspdf.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jspdf-autotable/2.3.2/jspdf.plugin.autotable.js"></script>
<script>
var doc = new jsPDF('p', 'pt');
var elem = document.getElementById("myTable");
var res = doc.autoTableHtmlToJson(elem);
doc.autoTable(res.columns, res.data);
doc.save("table.pdf");
</script>