简体   繁体   English

我如何使用 html2canvas 截取 HTML 的屏幕截图,Javascript 中的其他库

[英]How can i take Screenshot of HTML using html2canvas, Other Lib in Javascript

I use the html2canvas the take a screenshot and i found the problem.我使用 html2canvas 截图,我发现了问题。

if i refer image by URL, screenshot does not work.如果我参考 URL 的图像,屏幕截图不起作用。

code below, refer image by URL.下面的代码,参考 URL 的图像。

Image图片

when i running.当我跑步时。

Image图片

When i click download, Image is empty or blank.当我单击下载时,图像为空或空白。

Image图片

Save image from URL and refer into Img Tag从 URL 保存图像并参考 Img 标签

Image图片

When i click dowload当我点击下载

Image图片

This is my js function to download or take a screenshot.这是我的js function 下载或截图。

Image图片

As mentioned here https://html2canvas.hertzen.com/documentation正如这里提到的https://html2canvas.hertzen.com/documentation

All the images that the script uses need to reside under the same origin for it to be able to read them without the assistance of a proxy.脚本使用的所有图像都需要位于同一来源下,以便无需代理的帮助即可读取它们。

When you load it from same origin (your second attempt), it works.当您从同一来源(您的第二次尝试)加载它时,它可以工作。 Here is workaround - https://html2canvas.hertzen.com/proxy/这是解决方法 - https://html2canvas.hertzen.com/proxy/

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM