Я пытаюсь использовать библиотеку html2canvas в проекте Angular 8.
Я также пытался установить типы html2canvas в моем проекте с помощью npm install --save @types/html2canvas
, но он все еще не работает.
Шаблон:
<div #myform>
<form>
...
</form>
</div>
Компонент:
import { Component, OnInit, ViewChild, ElementRef } from '@angular/core';
import * as html2canvas from 'html2canvas';
@Component({
selector: 'app-pdf-viewer',
templateUrl: './pdf-viewer.component.html',
styleUrls: ['./pdf-viewer.component.scss']
})
export class PdfViewerComponent {
@ViewChild('myform', { static: false, read: ElementRef }) pdfForm: ElementRef;
constructor() {}
pdfDownload() {
html2canvas(this.pdfForm.nativeElement).then(canvas => {
const imgData = canvas.toDataURL('image/png');
document.body.appendChild(canvas);
});
}
}
Мое намерение состоит в том, чтобы отобразить форму как canvas, но приложение выдает ошибку:
ОШИБКА в src / app / grid / pdf-viewer / pdf-viewer.component.ts (19,5): ошибка TS2349: Невозможно вызвать выражение, тип которого не имеет подписи вызова. Введите 'typeof import ("myroute") ", вы не поддержали подписи вызовов.