Skip to content

Commit

Permalink
Merge pull request HalseySpicy#419 from limuen/fix-echarts
Browse files Browse the repository at this point in the history
fix: 🧩 修复echarts切换全屏后变小
  • Loading branch information
limuen authored Apr 24, 2024
2 parents 41b3eed + fc84fde commit 2a08f3f
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/components/ECharts/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
</template>

<script setup lang="ts" name="ECharts">
import { ref, onMounted, onBeforeUnmount, watch, computed, markRaw, nextTick } from "vue";
import { ref, onMounted, onBeforeUnmount, watch, computed, markRaw, nextTick, onActivated } from "vue";
import { EChartsType, ECElementEvent } from "echarts/core";
import echarts, { ECOption } from "./config";
import { useDebounceFn } from "@vueuse/core";
Expand Down Expand Up @@ -85,6 +85,12 @@ onMounted(() => {
window.addEventListener("resize", debouncedResize);
});
onActivated(() => {
if (chartInstance.value) {
chartInstance.value.resize();
}
});
onBeforeUnmount(() => {
chartInstance.value?.dispose();
window.removeEventListener("resize", debouncedResize);
Expand Down

0 comments on commit 2a08f3f

Please sign in to comment.