关于图片资源跨域,生成不显示问题?
服务端资源需要设置 : Access-Control-Allow-Origin
添加参数:useCORS:true, // 允许跨域
图片属性添加 crossorigin="anonymous"
楼主我看官网的生成图片是可以保存img的,为什么我弄的canvas 保存不了图片?
function saveImageInfo() { var mycanvas = document.getElementById("thecanvas"); var image = mycanvas.toDataURL("image/png"); var w = window.open('about:blank', 'image from canvas'); w.document.write("<img src='" + image + "' alt='from canvas'/>"); } function saveAsLocalImage() { var myCanvas = document.getElementById("thecanvas"); var image = myCanvas.toDataURL("image/png").replace("image/png", "image/octet-stream"); window.location.href = image; }