bubkoo / html-to-image

✂️ Generates an image from a DOM node using HTML5 canvas and SVG.
MIT License
5.79k stars 544 forks source link

htmltoimage doesn't work in production mode #62

Closed Roman-Cecile closed 4 years ago

Roman-Cecile commented 4 years ago

Hello, I've installed html-to-image in my project and it's work in development mode with this code :

htmltoimage.toJpeg(node, exportOptions).then(function (dataUrl) {
      const link = document.createElement("a");
      link.download = `${
        titleScreenShot === "" || titleScreenShot === "Title"
          ? `capture-${dateFormat(new Date(), "dd/mm/yyyy@h:MM:ss")}`
          : titleScreenShot
      } `;
      link.href = dataUrl;
      link.click();
    });

But when i push my project in production mode i get Uncaught TypeError: Cannot read property 'toJpeg' of undefined

Have you got advices to resolve this problem ?

Thanks

Roman-Cecile commented 4 years ago

I've resolved the problem. my version was 0.1.1 and with the last version, import has changed. So i change import htmltoimage from "html-to-image to import {jpeg} from "html-to-image and it's work. Thanks

biiibooo[bot] commented 3 years ago

This thread has been automatically locked because it has not had recent activity. Please open a new issue for related bugs and link to relevant comments in this thread.