Angular 中的 "error TS2349: This expression is not callable" 如何解决这个问题

How to fix this, "error TS2349: This expression is not callable" in Angular

我正在尝试使用 Canvas 进行报告。但是当我使用 ng serve 启动服务器时发生了这个错误 我需要解决这个问题。那么,我该如何解决这个错误?

.ts文件的代码如下,

import * as html2canvas from 'html2canvas';
 html2canvas(document.getElementById('result-table')).then(canvas => {
      let dateX = new Date();
      var imgWidth = 208;
      var pageHeight = 295;
      var imgHeight = canvas.height * imgWidth / canvas.width;
      var heightLeft = imgHeight;

      const contentDataURL = canvas.toDataURL('image/png')
      let pdf = new jsPDF('p', 'mm', 'a4'); 
      var position = 30;

      pdf.line(1, 1, 208, 1);
      pdf.text("Results", (imgWidth / 3.3), 12)
      pdf.line((imgWidth / 2.5) - 4, 15, 121, 15);
      pdf.setFontSize(9);
      pdf.text(`Category: ${this.dataArrr[0].cat_id}`, 5, 17)
      pdf.text(`Item: ${this.dataArrr[0].item_id}`, 5, 24)
    
      pdf.addImage(contentDataURL, 'PNG', 1, position, imgWidth, imgHeight)
      pdf.setFontSize(9);
      pdf.text("*This is an computer generated report!", 10, imgHeight + 40)
      pdf.text(`${dateX}`, 80, imgHeight + 40)
      pdf.save(`Results.pdf`);
    });
  }

当我使用ng serve启动服务器时,出现如下错误,


ERROR in src/app/audition-results/audition-results.component.ts:614:5 - error TS2349: This expression is not 
callable.

  Type 'typeof import("D:/Audition/sisi-arundathee/node_modules/html2canvas/dist/types/index")' has no call signatures.

     html2canvas(document.getElementById('result-table')).then(canvas => {

*目前,我正在使用 Angular 10.

我使用下面的命令导入canvas

import html2canvas from 'html2canvas'; 

而不是

import * as html2canvas from 'html2canvas';

现在可以使用了