一、問題描述
最近在開發 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