javascript - 导出 PNG 画布所有 div 内容时出错
问题描述
在 localhost 中,它的工作是将 div 导出到图像,将图像包含在另一个图像上。我需要创建动态身份证。
但是,本地项目其工作完美,但项目在线,不工作
- 我使用断头台仅缩放图像和移动
- 我的第一个图像模板是 div 内的 svg 作为背景图像
- 姓名、职务、编号员工及其显示
var test = $(".test").get(0);
$('.toCanvas').click(function(e) {
html2canvas(test).then(function(canvas) {
var canvasWidth = canvas.width;
var canvasHeight = canvas.height;
var img = Canvas2Image.convertToImage(canvas, canvasWidth, canvasHeight);
$('#save').click(function(e) {
let type = 'png'; // image type
w = canvasWidth;
h = canvasHeight;
Canvas2Image.saveAsImage(canvas, w, h, type, 'credencial');
});
});
});
我尝试了不同的选项,例如,生成图像到 php,保存,下载后,但问题相同,本地工作完美,但在线不工作
谢谢
解决方案
推荐阅读
- css - 如何使用引导 css 标题导航栏对齐
- python - 写入 CSV 给出,错误:无法将字符串转换为浮点数
- r - 如何提取字符串中某个单词之前的单词?
- java - 没有重叠字符的 JTextField 最大字符长度
- ruby-on-rails - 如何使用 react_rails 将子项传递给苗条模板中的组件
- python - 检查字符串列表以提取某些单词的有效方法
- go - 未拾取 PDF/A XMP 数据
- c# - 使用 SQL 查询在网格视图上连接当前和历史数据
- python - 在numpy中使用间接索引对多维数组求和的快速方法
- c++ - 为什么没有return语句的C++函数会返回一个值?