美文网首页
html2canvas配置

html2canvas配置

作者: 记忆是条狗 | 来源:发表于2022-07-06 15:50 被阅读0次
        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);
                })
        }
    

    相关文章

      网友评论

          本文标题:html2canvas配置

          本文链接:https://www.haomeiwen.com/subject/fosybrtx.html