1.报错
Failed to execute 'toDataURL' on 'HTMLCanvasElement': Tainted canvases may not be exported.
2.原因
图片的跨域会导致canvas.toDataURL()失败报错。
3.解决图片跨域
(1)打开跨域资源允许权限
var img=new Image();
img.crossOrigin="anonymous"; //关键
img.src="图片地址";
(2)存放图片地址的服务器也要开启跨域允许权限,不然会报错:No 'Access-Control-Allow-Origin' header is present on the requested resource.
4.或则让图片不跨域就行了。