【问题标题】:console error Use of deprecated autoTable initiation控制台错误使用已弃用的 autoTable 启动
【发布时间】:2022-01-04 04:36:47
【问题描述】:

早上好,伙计们,我正在使用 vuetify 开发 vue js,事实证明,当我把它生成一个 pdf 以通过 jspdf 和 autotable jspdf 打印它时,我在控制台中得到以下内容

这是我在 vue.js 中的代码

createPdf() {
  var doc = new jsPDF()
  var rows =[];
  
  var columns= [
    { header: 'Code', dataKey: 'code' },
    { header: 'Name', dataKey: 'namearticle' },
    { header: 'Category', dataKey: 'category' },
  ];
  this.articles.map(function(x){
    rows.push({code:x.code,namearticle:x.namearticle,category:x.category});
  });
  doc.autoTable(columns,rows)
  doc.save("table.pdf");
}

这是在 vue.js 的方法中,但这段代码有效,但在控制台中出现 使用已弃用的 autoTable 启动

【问题讨论】:

  • 我没有使用 jspdf 的经验,但是您尝试过使用 pdfmake 吗?我已经使用它 2 年了,我真的推荐它。 pdfmake.org/#

标签: vuejs2 vuetify.js jspdf jspdf-autotable


【解决方案1】:

早上好,我已经解决了旧代码问题如下

createPdf() {
  var doc = new jsPDF()
  var rows =[];
  this.articles.map(function(x){
          rows.push({code:x.code,namearticle:x.namearticle,category:x.category,stock:x.stock,price_sale:x.price_sale,numberstatate:x.numberstatate ? 'Activate' : 'Inactivate'});
  });
  doc.autoTable({
    columns:[
      { header: 'Code', dataKey: 'code' },
      { header: 'Name', dataKey: 'namearticle' },
      { header: 'Category', dataKey: 'category' },
      { header: 'Stock', dataKey: 'stock' },
      { header: 'Price Sale', dataKey: 'price_sale' },
      { header: 'State', dataKey: 'numberstatate' },
    ],
    body:rows,
    margin:{top:35},
    didDrawPage:function(data){
    doc.text("TOLIST ARTICLES", 20, 30);
  }})
  doc.save("table.pdf");
}

【讨论】:

    猜你喜欢
    • 2021-11-12
    • 1970-01-01
    • 1970-01-01
    • 2019-07-29
    • 1970-01-01
    • 2021-11-09
    • 2023-02-16
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多