tsayen / dom-to-image

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

toPng 本地是可以的,部署到线上之后出现这问题 #339

Open shy19940217 opened 4 years ago

shy19940217 commented 4 years ago

Uncaught TypeError: Failed to execute 'readAsDataURL' on 'FileReader': parameter 1 is not of type 'Blob'.

BluesMardrid commented 4 years ago

我也遇到这个问题了,请问你解决了么?

anyisky commented 3 years ago

我也遇到这样的情况,请问你解决了么?

image

我的报错信息不太一样

是在 react 项目中使用

BluesMardrid commented 3 years ago

我也遇到这样的情况,请问你解决了么?

image

我的报错信息不太一样

是在 react 项目中使用

我解决了,找到这个方法,把then(embedFonts)这一行注释掉就行 image

anyisky commented 3 years ago

我也遇到这样的情况,请问你解决了么? image 我的报错信息不太一样 是在 react 项目中使用

我解决了,找到这个方法,把then(embedFonts)这一行注释掉就行 image

我改换了混淆插件,取消对 dom-to-image 的混淆处理解决了这问题 项目里用的插件是 terser-webpack-plugin,换成 uglifyjs-webpack-plugin,排除掉 node modules 的混淆处理,就正常使用了

OXFord88 commented 2 years ago

Uncaught TypeError: Failed to execute 'readAsDataURL' on 'FileReader': parameter 1 is not of type 'Blob'.

image 这个是啥问题引起的

echoego commented 1 year ago

Uncaught TypeError: Failed to execute 'readAsDataURL' on 'FileReader': parameter 1 is not of type 'Blob'.

image 这个是啥问题引起的

在build好的dist文件夹中搜索 readAsDataURL(s.response),找到对应的文件打开,并将其修改为readAsDataURL(new Blob([s.response], { type: s.response.type })),然后保存,重新zip并上传上线。 问题应该是处在 定义response type为blob的过程失效了,我看返回response的type为空字符串。