fix: echarts resize error (#622)

This commit is contained in:
Cosmos 2023-10-30 13:11:41 +08:00 committed by GitHub
parent cc84c85013
commit 03e959696e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1,16 +1,14 @@
import * as echarts from 'echarts/core';
import { onMounted, onUnmounted, Ref, ref } from 'vue';
import { onMounted, onUnmounted, Ref, ref, ShallowRef, shallowRef } from 'vue';
/**
* eChart hook
* @param domId
* @param chart
*/
export const useChart = (domId: string): Ref<echarts.ECharts> => {
export const useChart = (domId: string): ShallowRef<echarts.ECharts> => {
let chartContainer: HTMLCanvasElement;
const selfChart = ref<echarts.ECharts | any>();
const selfChart = shallowRef<echarts.ECharts | any>();
const updateContainer = () => {
// TODO resize 报错,响应式的问题,待处理
selfChart.value.resize({
width: chartContainer.clientWidth,
height: chartContainer.clientHeight,