taro 引入"html2Canvas"后, 保存图片报错

n6lpvg4x  于 5个月前  发布在  其他
关注(0)|答案(3)|浏览(47)

相关平台

微信小程序

小程序基础库: 2.30.0
使用框架: React

复现步骤

html2canvas(document.querySelector("#shareCanvasDialog"), {
allowTaint: false,
useCORS: true,
scrollY: 0,
scale: 2
}).then(async canvasRes => {
console.log("canvasRes ", canvasRes);
})
}}

期望结果

正常保存图片

实际结果

微信开发工具报错如下:

TypeError: Cannot read property 'TEXT_NODE' of undefined
at vo (index.js?t=wechat&s=1676596508698&v=a16929ea6ef629e3775d2c2a5183a436:2)
at A.cloneNode (index.js?t=wechat&s=1676596508698&v=a16929ea6ef629e3775d2c2a5183a436:2)
at new A (index.js?t=wechat&s=1676596508698&v=a16929ea6ef629e3775d2c2a5183a436:2)
at index.js?t=wechat&s=1676596508698&v=a16929ea6ef629e3775d2c2a5183a436:2
at i (index.js?t=wechat&s=1676596508698&v=a16929ea6ef629e3775d2c2a5183a436:2)
at Object.next (index.js?t=wechat&s=1676596508698&v=a16929ea6ef629e3775d2c2a5183a436:2)
at index.js?t=wechat&s=1676596508698&v=a16929ea6ef629e3775d2c2a5183a436:2
at new Promise ()
at s (index.js?t=wechat&s=1676596508698&v=a16929ea6ef629e3775d2c2a5183a436:2)
at Ja (index.js?t=wechat&s=1676596508698&v=a16929ea6ef629e3775d2c2a5183a436:2)(env: Windows,mp,1.06.2210310; lib: 2.30.1)

环境信息

Taro CLI 3.5.10 environment info:
    System:
      OS: Windows 10
    Binaries:
      Node: 16.13.1 - C:\Program Files\nodejs\node.EXE
      Yarn: 1.22.19 - C:\Program Files\nodejs\yarn.CMD
      npm: 8.1.2 - C:\Program Files\nodejs\npm.CMD
gr8qqesn

gr8qqesn1#

微信小程序使用自己的 Canvas 2D API,与 Web 不通用,试着找找小程序版的实现

rdrgkggo

rdrgkggo2#

Taro是不是没法用html2canvas?

x33g5p2x

x33g5p2x3#

请问后面怎么解决的?用了什么插件呢

相关问题