mycomponent.ts
import jsPDF from 'jspdf';
import autoTable from 'jspdf-autotable';
export class Component implements OnInit {
.
.
.
exportPdf() {
const doc = new jsPDF('p', 'pt');
columns = [...]
autoTable(doc, {
columns: this.columns,
body: this.data,
didDrawPage: (dataArg) => {
doc.text('data', dataArg.settings.margin.left, 10);
}
});
doc.save('data.pdf');
}
}
package.json
"dependencies": {
"jspdf": "^2.5.1",
"jspdf-autotable": "^3.5.23"
}
我用npm i jspdf和npm i jspdf-autotable安装了我的npm包,但同样的错误仍然存在。我不知道该怎么办。版本错了吗?
2条答案
按热度按时间bnlyeluc1#
您必须安装
@types/jspdf
和@types/jspdf-autotable
作为dev-dependencies。如果使用
yarn
:对于
npm
用途:px9o7tmv2#
npm install jspdf jspdf-autotable
对于任何依赖性错误,执行以下语句
npm install jspdf jspdf-autotable --force