Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

canvas 调用toDataUrl 报污染的画布无法导出 #39

Open
baby2011 opened this issue Apr 18, 2018 · 2 comments
Open

canvas 调用toDataUrl 报污染的画布无法导出 #39

baby2011 opened this issue Apr 18, 2018 · 2 comments

Comments

@baby2011
Copy link

No description provided.

@baby2011
Copy link
Author

baby2011 commented Apr 18, 2018

你好,我在看http://fex.baidu.com/blog/2015/11/convert-svg-to-png-at-frontend/
这篇文章的时候发现canvas 调用toDataUrl 报污染的画布无法导出错误,请问如何解决呢?图片资源响应头设置了cors也不行

@xiaosongxiaosong
Copy link

@baby2011imgcrossOrigin 设置为 anonymous

const img = new Image();
img.crossOrigin = 'anonymous';
img.onload = () => {
  // draw img
};
img.src = 'http://example.com/image';

https://developer.mozilla.org/zh-CN/docs/Web/HTML/CORS_enabled_image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants