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 }) // 上传预览图