h5 图片生成

createImg(store, data) {
let timer = setTimeout(function (params) {
let _canvas = document.querySelector(".setPictureSection");
var w = parseInt(window.getComputedStyle(_canvas).width);
var h = parseInt(window.getComputedStyle(_canvas).height);
//将canvas画布放大若干倍,然后盛放在较小的容器内,就显得不模糊了
var canvas2 = document.createElement("canvas");
var scale = 2; canvas2.width = w * 2;
canvas2.height = h * 2;
canvas2.style.width = w + "px";
canvas2.style.height = h + "px";
canvas2.getContext("2d").scale(scale, scale); html2canvas(document.querySelector(".setPictureSection"), {
// allowTaint: true,
// taintTest: false,
scale: 1,
dpi: window.devicePixelRatio * 5,
// canvas: canvas2,
userCORS: true,
backgroundColor: '#ffffff',
width: w,
height: h,
x: 0,
y: 0,
}).then(function (canvas) {
//document.body.appendChild(canvas);
//canvas转换成url,然后利用a标签的download属性,直接下载,绕过上传服务器再下载
document.querySelector(".down")
.setAttribute("href", canvas.toDataURL("image/png", 1.0));
$(".down")[0].click(); });
timer = null;
}, 350)
},

  

上一篇:解决selenium.common.exceptions.WebDriverException: Message: 'chromedriver' executable needs to be in PATH. Please see https://sites.google.com/a/chromium.org/chromedriver/home


下一篇:.net 环境配置