html2canvas解决保存图片模糊问题


用的是官网的CDN:http://html2canvas.hertzen.com/dist/html2canvas.min.js
    function comfirmSaveImg() {
        var copyDom = $(".content");//要保存的dom
        var width = copyDom.offsetWidth; //dom宽
        var height = copyDom.offsetHeight; //dom高
        var scale = 2; //放大倍数
        html2canvas(copyDom[0], {
            dpi: window.devicePixelRatio * 2,
            scale: scale,
            width: width,
            heigth: height,
            useCORS: true // 【重要】开启跨域配置
        }).then(function(canvas) {
            var url = canvas.toDataURL();
        var triggerDownload = $("").attr("href", url).attr("download", "详情.png").appendTo("body");
        triggerDownload[0].click();
        triggerDownload.remove();
           
        });

    }

 来源:https://www.cnblogs.com/stt-bky/p/9518591.html