html2canvas 在IOS系统13.4以上失效的问题解决方法
一、问题描述
最近在开发 html2canvas 的时候,突然发现,html2canvas在IOS13.4.1系统中调用失败。后马上去github上查看是否有同道中人遇到类似问题。
参考链接:https://github.com/niklasvh/html2canvas/issues/2229
二、解决方案
1.首先将 package.json 中的 html2canvas 版本降低为【1.0.0-rc.4】
版本降低方法
首先移除 html2canvas 【npm uninstall html2canvas】
然后安装指定版本 【npm install --save html2canvas@1.0.0-rc.4】
dependencies": { "html2canvas": "^1.0.0-rc.4", "less": "^3.11.1", "less-loader": "^4.1.0", "vue": "^2.5.2", "vue-router": "^3.0.1" },
2.如果上述无法解决你的问题 再进行第2步
先点下方的参考链接下载修复过的html2canvas.js文件,在按下面的方法改代码
// 修改后代码 主要将 html2canvas 修改为 (window.html2canvas || html2canvas) (window.html2canvas || html2canvas)(this.$refs.htmlCanvas, { backgroundColor: null }).then((canvas) => { let dataURL = canvas.toDataURL("image/png"); this.shareImgUrl = dataURL; console.log(this.dataURL) }); }
参考链接:https://github.com/FEA-Dven/html2Canvas
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步