問題
- 今日同事開發(fā)海報生成頁面的過程中,在 ios 13.4.1 系統(tǒng) 中,微信瀏覽器使用 html2canvas 無任何反饋,其他系統(tǒng)版本瀏覽器頁面都無問題。
后果
- 海報無法生成,導(dǎo)致用戶無法分享海報。
原因
- Promise documentClone.fonts.ready not resolve in file document-cloner.ts.
- github 上有問題描述: https://github.com/niklasvh/html2canvas/issues/2205
解決方案
- 對 html2canvas 由 1.0.0-rc. 5 回退版本到 1.0.0-rc. 3 或者 1.0.0-rc. 4即可。
npm install html2canvas@1.0.0-rc.3
npm install html2canvas@1.0.0-rc.4
兩者任選一個,這里有個坑,如果項(xiàng)目有yarn.lock文件,或者package.lock.json文件,請刪除掉該文件,再把 node_modules 刪除,重新安裝依賴,否則會出現(xiàn)回退版本不成功的問題。
最后請使用命令查看依賴是否回退成功。我在這里遇到問題是執(zhí)行回退版本命令之后,用 npm ls html2canvas 命令查看一直是 rc5 的版本,后來依照上面的方法得以解決。
npm ls html2canvas
- 這個命令是查看本地包版本,比較費(fèi)時,請等一等,如果顯示的是 html2canvas@1.0.0-rc.3 或者 html2canvas@1.0.0-rc.4 就說明回退成功。

回退成功提示.jpg