fix: 修复 echart 无法正确渲染的问题

This commit is contained in:
Huangzhe
2025-05-28 23:33:39 +08:00
parent 966e56ad74
commit e89f554830
2 changed files with 9 additions and 2 deletions

View File

@@ -1,5 +1,5 @@
<script setup lang="ts">
import { computed, nextTick, ref, useTemplateRef, watch } from 'vue';
import { computed, nextTick, onErrorCaptured, ref, useTemplateRef, watch } from 'vue';
import { useSetPieChart } from '@/hooks/chart/usePieChart';
import {
formatData,
@@ -112,6 +112,11 @@ const chartVisible = computed(() => {
return series.value?.data?.length;
});
onErrorCaptured((err) => {
console.log(`err`, err);
return false;
});
</script>
<template>

View File

@@ -17,8 +17,10 @@ function useSetPieChart(
let chartInstance: any;
onMounted(() => {
console.log(`1233313123`,dom.value, series.value);
// 检测边界范围 dom 和 series 是否存在
if (!dom.value && !series) return;
if (!dom.value || !series.value) return;
// 在 dom 挂载之后,显示饼图
// 在 dom 挂载之后,显示饼图