We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
加载不同域名下的图片,想问问有办法解决跨域请求吗。 谢谢。
The text was updated successfully, but these errors were encountered:
跨域不是客户端能处理的,也要服务端支持访问的
Sorry, something went wrong.
可以通过请求拿到图片的二进制数据,然后写入到Img标签中。canvas中加载img标签。如果图片请求就是跨域的,那么需要服务端支持了
window.fetch(url).then(response => { respose.blob().then((result) => { const url = URL.createObjectURL(result); const image = new Image(); image.crossOrigin = 'Anonymous' image.onload = () => { resolve({ width: image.width, height: image.height, src: url, image, }); } image.onerror = reject; image.src = url; }).catch(() => null) }).catch(() => null)
No branches or pull requests
加载不同域名下的图片,想问问有办法解决跨域请求吗。
谢谢。
The text was updated successfully, but these errors were encountered: