From 95abe061072b79dca9cbba405ebc1f2f66ca6bec Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=9B=AA=E5=BF=86?= <1455668754@qq.com> Date: Mon, 29 Jul 2024 15:11:06 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20Echarts=E5=88=9D=E5=A7=8B=E5=AE=BD?= =?UTF-8?q?=E5=BA=A6=E7=9B=91=E5=90=AC=E4=BF=AE=E5=A4=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/hooks/web/useECharts.ts | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/hooks/web/useECharts.ts b/src/hooks/web/useECharts.ts index c5478d79..6eac15f9 100644 --- a/src/hooks/web/useECharts.ts +++ b/src/hooks/web/useECharts.ts @@ -1,8 +1,8 @@ import type { EChartsOption } from 'echarts'; import type { Ref } from 'vue'; +import { computed, nextTick, ref, unref, watch } from 'vue'; import { useTimeoutFn } from '@vben/hooks'; import { tryOnUnmounted, useDebounceFn } from '@vueuse/core'; -import { unref, nextTick, watch, computed, ref } from 'vue'; import { useEventListener } from '@/hooks/event/useEventListener'; import { useBreakpoint } from '@/hooks/event/useBreakpoint'; import echarts from '@/utils/lib/echarts'; @@ -49,6 +49,10 @@ export function useECharts( listener: resizeFn, }); removeResizeFn = removeEvent; + + const resizeObserver = new ResizeObserver(resizeFn); + resizeObserver.observe(el); + const { widthRef, screenEnum } = useBreakpoint(); if (unref(widthRef) <= screenEnum.MD || el.offsetHeight === 0) { useTimeoutFn(() => { @@ -64,7 +68,7 @@ export function useECharts( useTimeoutFn(() => { setOptions(unref(getOptions)); resolve(null); - }, 30); + }, 50); } nextTick(() => { useTimeoutFn(() => {