var copyDom = document.querySelector('.fenxiang1');
var width = copyDom.offsetWidth;//dom宽
var height = copyDom.offsetHeight;//dom高
console.log(JSON.stringify(copyDom));
console.log(width);
console.log(height);
var scale = 2;//放大倍数
html2canvas(copyDom, {
dpi: window.devicePixelRatio * 2,
scale: scale,
width: width,
heigth: height,
}).then(function (canvas) {
var dataURL = canvas.toDataURL();
console.log(dataURL);
that.canvas = dataURL.split(',')[1];
$(".i-d-canvas").attr('src', dataURL);
myApp.preloader.hide();
api.addEventListener({
name: 'longpress'
}, function (ret, err) {
ac5.open();
});
});
//要放canvas的img
//要转化的弹窗开始
{{name}}
券后价:¥{{xian_price}}
用到的js:
标签:canvas,dataURL,log,copyDom,var,html,清晰度,console
来源: https://www.cnblogs.com/shark1100913/p/11003231.html