html2canvas(domObj, {
useCORS: true,//Whether to attempt to load cross-origin images as CORS served, before reverting back to proxy
allowTaint: false,//Whether to allow cross-origin images to taint the canvas
height: domObj.offsetHeight,//Define the heigt of the canvas in pixels. If null, renders with full height of the window
width: domObj.offsetWidth,
windowWidth: document.body.scrollWidth,
windowHeight: document.body.scrollHeight,
logging: false,//Whether to log events in the console
x: 0,
y: scrollTop, // 用网页滚动的高度定位y轴顶点
dpi: window.devicePixelRatio,
scale: 1,
backgroundColor: null,//Canvas background color, if none is specified in DOM. Set undefined for transparent
letterRendering: true,//Whether to render each letter seperately. Necessary if letter-spacing is used
onclone (doc) {
console.log(doc);
}
}).then(canvas => {
// 微信里可长按保存或转发
const imgData = canvas.toDataURL('image/png');
console.log(imgData);
})
}
网友评论