html2canvas使用方式

代码如下:

createposter() {

      const that = this;

      // 生成海报

      window.scroll(0, 0);

      const domObj = document.getElementById('posterHtml');

      html2canvas(domObj, {

         useCORS: true,

         allowTaint: true,

         taintTest: false,

         logging: false,

         letterRendering: true,

         onclone(doc) {

                let e = doc.querySelector('#posterHtml')

                e.style.display = 'block'

         }

}).then(function (canvas) {

        that.img_src = canvas.toDataURL('image/png');

        that.isShowMask = true;

})

}

注意:当图片是跨域的时候,应注意给img便签添加 crossorigin="anonymous"属性

二手闲置小程序 免费信息发布系统功能源码(小程序+php后台管理)

https://blog.csdn.net/MPQ1314/article/details/87162363

电商商城小程序 小程序+php后台管理系统功能源码

https://blog.csdn.net/MPQ1314/article/details/103723983

发布了40 篇原创文章 · 获赞 22 · 访问量 1万+

猜你喜欢

转载自blog.csdn.net/MPQ1314/article/details/100691324
今日推荐