TypeError: c.autoTable is not a function
See original GitHub issuehello,你好! it can works in vue3 dev env. but when i build it ,it can not works in product env.
"jspdf": "^2.5.0",
"jspdf-autotable": "^3.5.23",
import jsPDF from "jspdf";
import "jspdf-autotable";
const print = async () => {
const PageMargin = { top: 20, right: 10, bottom: 15, left: 10 };
const doc = new jsPDF({
orientation: "p",
unit: "mm",
format: "a4",
});
await something .......
doc.autoTable({
styles: { font: "hansans-normal" },
columnStyles: { europe: { halign: "center" } }, // European countries centered
body: state.datasource,
columns: state.pdfheader,
startY: startY, //第一次
margin: PageMargin,
});
}
TypeError: c.autoTable is not a function
Issue Analytics
- State:
- Created 2 years ago
- Comments:8 (2 by maintainers)
Top Results From Across the Web
jsPDF AutoTable - autoTable is not a function
I have jspdf and jspdf-autotable installed via npm, I confirmed they are in the node modules. I've imported both plugins this way: import...
Read more >simonbengtsson/jsPDF-AutoTable - Gitter
Third time hit the generatePdf it genereate pdf properly,. Issue 2: Sometime its throws an error saying TypeError: doc.autoTable is not a function....
Read more >autoTable is not a function error when using jspdf in ...
Hello All, I face issue with using jsPDF library in sap ui5. I have written the below code in my controller. var doc...
Read more >jsPDF-AutoTable
I'm trying to create a table using jspdf autotable but i got an issue in html:"tableId" it is not printing all the loop...
Read more >jspdf-autotable
Generate pdf tables with javascript (jsPDF plugin). Latest version: 3.5.28, last published: a month ago. Start using jspdf-autotable in your ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I had meet the same problem today, and I use
Vite
which userollup-commonjs-plugin
to convert commonjs module to ESM during build.After looking into dist code, I found somehow commonjs plugin did not convert
require("jspdf")
:which should be something like this:
since autotabe need apply itself as plugin to jspdf, this is the immediate cause of the problem.
After further investigation, I found in Vite version 2.6.3, they upgrade commonjs plugin to version 21.0.0 upgrade to @rollup/plugin-commonjs 21.x and what happened in commonjs plugin to version 21.0.0?
they set
ignoreTryCatch
default astrue
use safe default value for ignoreTryCatchand, this repo, use try catch when require
jspdf
So, in conclusion, to solve this problem, explicitly set
ignoreTryCatch
tofalse
:help me 55555555