tsayen / dom-to-image

Generates an image from a DOM node using HTML5 canvas
Other
10.34k stars 1.68k forks source link

Getting node from DOMParser results in a data string of 'data:,' #363

Closed Summer-andy closed 3 years ago

Summer-andy commented 3 years ago

domtoimage .toPng(domRef.current, { quality: 0.5 }) .then(function(dataUrl) { console.log(dataUrl); var link = document.createElement('a'); link.download = card.jpeg; link.href = dataUrl; link.click(); });

dataUrl is 'data:,'

axtlive commented 3 years ago

I met the same case, have you solve it ?

Summer-andy commented 3 years ago

yeah, i use other plugin to replace it.

axtlive commented 3 years ago

I found the reason finally,for the dom u choose to use must be in the document (can be seen in page ) ,otherwise U will get 'data:; ' ,if the dom were create by using 'document. createElement' the dom just in the memory ,not in document(page)

在 2021年3月17日,21:15,Andy @.***> 写道:

 yeah, i use other plugin to replace it.

— You are receiving this because you commented. Reply to this email directly, view it on GitHub, or unsubscribe.

Summer-andy commented 3 years ago

good!

axtlive commented 3 years ago

他妈的,中国人,都在上海,讲锤子英语。