From 68c68e96b1144964527a0b639099cc99daf96872 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=A5=94=E8=B7=91=E7=9A=84=E9=9D=A2=E6=9D=A1?= <1262327911@qq.com> Date: Mon, 29 Aug 2022 21:35:51 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E5=B0=9D=E8=AF=95=E8=A7=A3=E5=86=B3?= =?UTF-8?q?=E8=83=8C=E6=99=AF=E5=9B=BE=E7=89=87=E6=97=A0=E6=B3=95=E6=88=AA?= =?UTF-8?q?=E5=9B=BE=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/utils/utils.ts | 4 +++- src/views/chart/hooks/useSync.hook.ts | 4 +++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/src/utils/utils.ts b/src/utils/utils.ts index 43a3746c..2604efa9 100644 --- a/src/utils/utils.ts +++ b/src/utils/utils.ts @@ -154,7 +154,9 @@ export const canvasCut = (html: HTMLElement | null, callback?: Function) => { } html2canvas(html, { - backgroundColor: null + backgroundColor: null, + allowTaint: true, + useCORS: true }).then((canvas: HTMLCanvasElement) => { window['$message'].success('导出成功!') downloadByA(canvas.toDataURL(), undefined, 'png') diff --git a/src/views/chart/hooks/useSync.hook.ts b/src/views/chart/hooks/useSync.hook.ts index 8e869a4f..943bbf57 100644 --- a/src/views/chart/hooks/useSync.hook.ts +++ b/src/views/chart/hooks/useSync.hook.ts @@ -179,7 +179,9 @@ export const useSync = () => { const range = document.querySelector('.go-edit-range') as HTMLElement // 生成图片 const canvasImage: HTMLCanvasElement = await html2canvas(range, { - backgroundColor: null + backgroundColor: null, + allowTaint: true, + useCORS: true }) // 上传预览图