fix(hooks): 修改在使用useEcharts时, getInstance无法获取到最新的echarts实例的问题 (#2650)

This commit is contained in:
Lantz 2023-03-29 14:58:18 +08:00 committed by GitHub
parent 4c63b1abb7
commit 3a1ec7ac86
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 18 additions and 15 deletions

View File

@ -60,11 +60,12 @@ export function useECharts(
function setOptions(options: EChartsOption, clear = true) {
cacheOptions.value = options;
return new Promise((resolve) => {
if (unref(elRef)?.offsetHeight === 0) {
useTimeoutFn(() => {
setOptions(unref(getOptions));
resolve(null);
}, 30);
return;
}
nextTick(() => {
useTimeoutFn(() => {
@ -76,8 +77,10 @@ export function useECharts(
clear && chartInstance?.clear();
chartInstance?.setOption(unref(getOptions));
resolve(null);
}, 30);
});
});
}
function resize() {