相关平台
微信小程序
小程序基础库: 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
3条答案
按热度按时间gr8qqesn1#
微信小程序使用自己的 Canvas 2D API,与 Web 不通用,试着找找小程序版的实现
rdrgkggo2#
Taro是不是没法用html2canvas?
x33g5p2x3#
请问后面怎么解决的?用了什么插件呢