From 41a6f5961783ea17f998b7701e20571735eee998 Mon Sep 17 00:00:00 2001 From: honorsuper Date: Tue, 9 Aug 2022 10:13:36 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E5=A2=9E=E5=8A=A0=E4=B8=BB=E5=8A=A8?= =?UTF-8?q?=E9=94=80=E6=AF=81echarts=E5=AE=9E=E4=BE=8B=E6=96=B9=E6=B3=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/hooks/web/useECharts.ts | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/src/hooks/web/useECharts.ts b/src/hooks/web/useECharts.ts index 2463b76..874c489 100644 --- a/src/hooks/web/useECharts.ts +++ b/src/hooks/web/useECharts.ts @@ -97,12 +97,7 @@ export function useECharts( } ); - tryOnUnmounted(() => { - if (!chartInstance) return; - removeResizeFn(); - chartInstance.dispose(); - chartInstance = null; - }); + tryOnUnmounted(disposeInstance); function getInstance(): echarts.ECharts | null { if (!chartInstance) { @@ -111,10 +106,18 @@ export function useECharts( return chartInstance; } + function disposeInstance(){ + if (!chartInstance) return; + removeResizeFn(); + chartInstance.dispose(); + chartInstance = null; + } + return { setOptions, resize, echarts, getInstance, + disposeInstance }; }