feat: 增加主动销毁echarts实例方法

This commit is contained in:
honorsuper
2022-08-09 10:13:36 +08:00
parent 1a7eaf7efb
commit 41a6f59617

View File

@@ -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
};
}