The picture is placed on Youpaiyun. When canvas calls the picture, todataURl will report an error in the end. Is there any solution?
Baidu also looked at many solutions but none of them could be implemented. .
Error message:
Uncaught DOMException: Failed to execute 'toDataURL' on 'HTMLCanvasElement': Tainted canvases may not be exported.
If it is new Image()
, add the following settings:
// 引用外部圖片,需設(shè)置 crossOrigin 屬性,否則 toDataURL 調(diào)用異常
image.setAttribute('crossOrigin', 'anonymous');
Reference question: /q/10...