NervJS / taro

开放式跨端跨框架解决方案,支持使用 React/Vue/Nerv 等框架来开发微信/京东/百度/支付宝/字节跳动/ QQ 小程序/H5/React Native 等应用。 https://taro.zone/
https://docs.taro.zone/
Other
35.58k stars 4.79k forks source link

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

Open tilkofjin opened 1 year ago

tilkofjin commented 1 year ago

相关平台

微信小程序

小程序基础库: 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
ruidoc commented 1 year ago

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

Lxxsss commented 1 year ago

Taro是不是没法用html2canvas?

Luolovehui commented 1 year ago

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