Failed to execute 'toDataURL' on 'HTMLCanvasElement,在canvas.toDataURL()執行時候報錯解決方案

 
添加跨域條件   crossorigin="anonymous"

 

【Redirect at origin 'http://xxx.xx.com' has been blocked from loading by Cross-Origin Resource Sharingvue

policy: No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://sub2.xx.com' is therefore not allowed access.】git

 

var  img =  new  Image;
img.onload = myLoader;
img.crossOrigin =  'anonymous' //可選值:anonymous,*  
img.src =  'http://....' ;

 

或者是HTML中   <img src="" id="" crossorigin="anonymous">github

 

視頻的話同上,<video width="320" height="240" controls="controls"  crossorigin="anonymous"></video>npm

若是視頻 video.crossOrigin = 'anonymous';  報錯的話,能夠在標籤上面加該屬性。跨域

 

我的博客 :不少好用的 npm 包 , 能夠看看  https://gilea.cn/ ide

github:  https://github.com/longfei59418888/vui   (很不錯的vue2.0組件庫,記得給一個 start,之後有一塊兒討論,各類好組件)ui

相關文章
相關標籤/搜索