我正在使用 html2canvas.js,它在 chrome 中 100% 正常工作,而在 firefox 中它没有显示一些 div,它们是我目标 div 中的箭头,我只是将图像转换为 base64,然后通过 ajax 将其发送到我保存图像和生成pdf。在 chrome 图像和 pdf 上都与目标 div 100% 匹配,而当我尝试使用 mozilla 时,它不会在图像中呈现一些箭头,这是我的 js 代码
html2canvas(div, {
canvas: canvas,
height: useWidth,
width: useHeight,
onrendered: function (canvas) {
m_intSelectedProjectID = parseInt(m_intSelectedProjectID)
var image = canvas.toDataURL("image/png");
var l_strBase64 = image.replace('data:image/png;base64,', '');
var name = 'test'
$.ajax({
type: "POST",
url: "PTServiceRoutines.aspx/AjaxSaveImageFile",
data: "{'buffer':'" + l_strBase64 + "','p_intSelectedProjectID':'" + m_intSelectedProjectID + "','p_strViewMode':'" + p_strViewMode +"'}",
contentType: "application/json; charset=utf-8",
dataType: "json",
success: successAjaxSaveImageFile,
failure: failureAjaxSaveImageFile,
error: errorAjaxSaveImageFile
});
return false;
}
});
我不认为有任何需要从服务器端显示代码,因为当我在 html 上绑定(bind)渲染图像时,即使缺少箭头,我也分别从 chrome 和 firefox 上传图像。
最佳答案
我用 .png 扩展名保存图像,在 firefox 中遇到问题,而不是用 .jpg 扩展名保存图像,它解决了我的问题。
关于css - firefox 上的 html2canvas 图像问题 在 chrome 上工作正常,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50323795/