首页 > 解决方案 > 导出 PNG 画布所有 div 内容时出错

问题描述

在 localhost 中,它的工作是将 div 导出到图像,将图像包含在另一个图像上。我需要创建动态身份证。

但是,本地项目其工作完美,但项目在线,不工作

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,保存,下载后,但问题相同,本地工作完美,但在线不工作

谢谢

标签: javascriptjquerycanvas

解决方案


推荐阅读