mirror of
https://github.com/jekip/naive-ui-admin.git
synced 2026-02-04 13:42:27 +08:00
Merge pull request #161 from honorsuper/patch-1
feat: 增加主动销毁echarts实例方法
This commit is contained in:
@@ -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
|
||||
};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user