mirror of
https://github.com/jekip/naive-ui-admin.git
synced 2026-02-13 17:52:28 +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(() => {
|
tryOnUnmounted(disposeInstance);
|
||||||
if (!chartInstance) return;
|
|
||||||
removeResizeFn();
|
|
||||||
chartInstance.dispose();
|
|
||||||
chartInstance = null;
|
|
||||||
});
|
|
||||||
|
|
||||||
function getInstance(): echarts.ECharts | null {
|
function getInstance(): echarts.ECharts | null {
|
||||||
if (!chartInstance) {
|
if (!chartInstance) {
|
||||||
@@ -111,10 +106,18 @@ export function useECharts(
|
|||||||
return chartInstance;
|
return chartInstance;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function disposeInstance(){
|
||||||
|
if (!chartInstance) return;
|
||||||
|
removeResizeFn();
|
||||||
|
chartInstance.dispose();
|
||||||
|
chartInstance = null;
|
||||||
|
}
|
||||||
|
|
||||||
return {
|
return {
|
||||||
setOptions,
|
setOptions,
|
||||||
resize,
|
resize,
|
||||||
echarts,
|
echarts,
|
||||||
getInstance,
|
getInstance,
|
||||||
|
disposeInstance
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user