Home > Net >  Angular 12 : c.getComputedStyle is not a function
Angular 12 : c.getComputedStyle is not a function

Time:10-12

I'm using the new dom-to-image lib and I'm facing this error when I try to call the toPng method inside of a component.

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 */

The leafletMap exists in my components HTML and when I log it, it contains a HtmlNativeElement

CodePudding user response:

Seems there is an issue with the latest version of the lib. Try using this version:

"dom-to-image-more": "2.8.0"

I have created a working StackBlitz, click on download button and see the result.

  • Related