html2canvas图片跨域

2021-11-08 10:29:42 浏览数 (1)

allowTaint false Whether to allow cross-origin images to taint the canvas 默认是false

代码语言:javascript复制
    <div id="capture"  >
        <h4 style="color: #000; ">Hello world!</h4>
        <img src="http://thirdwx.qlogo.cn/mmopen/H1d1jwBqG4QzZf8kHtJ5LLer7bCvBJ1aDbOFrFuhCibQTlhhDNicxjWXXRbGN49jUiaicmDrc1icGp7YdENUvicogsf4wIHrDOcAV7/132">
    </div>
代码语言:javascript复制
html2canvas(document.querySelector("#capture"),{allowTaint:true}).then(canvas => {
    document.body.appendChild(canvas)
});

0 人点赞