Angular 12 : c.getComputedStyle 不是函数
Angular 12 : c.getComputedStyle is not a function
我正在使用新的 dom-to-image 库,当我尝试调用组件内部的 toPng
方法时遇到此错误。
import domtoimage from 'dom-to-image-more';
export class MyComponent {
@ViewChild('leafletMap') leafletMap: ElementRef;
downloadMap = (): void => {
//error happens here
domtoimage.toPng(this.leafletMap.nativeElement).then((img: any) => {
console.log(img);
});
};
}
/* of course this is simplified */
我的组件中存在 leafletMap HTML,当我记录它时,它包含一个 HtmlNativeElement
最新版本的库似乎有问题。尝试使用此版本:
"dom-to-image-more": "2.8.0"
我已经创建了一个工作 StackBlitz,点击下载按钮并查看结果。
我正在使用新的 dom-to-image 库,当我尝试调用组件内部的 toPng
方法时遇到此错误。
import domtoimage from 'dom-to-image-more';
export class MyComponent {
@ViewChild('leafletMap') leafletMap: ElementRef;
downloadMap = (): void => {
//error happens here
domtoimage.toPng(this.leafletMap.nativeElement).then((img: any) => {
console.log(img);
});
};
}
/* of course this is simplified */
我的组件中存在 leafletMap HTML,当我记录它时,它包含一个 HtmlNativeElement
最新版本的库似乎有问题。尝试使用此版本:
"dom-to-image-more": "2.8.0"
我已经创建了一个工作 StackBlitz,点击下载按钮并查看结果。