fix(hooks): 修改在使用useEcharts时, getInstance无法获取到最新的echarts实例的问题 (#2650)
This commit is contained in:
parent
4c63b1abb7
commit
3a1ec7ac86
|
|
@ -60,23 +60,26 @@ export function useECharts(
|
||||||
|
|
||||||
function setOptions(options: EChartsOption, clear = true) {
|
function setOptions(options: EChartsOption, clear = true) {
|
||||||
cacheOptions.value = options;
|
cacheOptions.value = options;
|
||||||
if (unref(elRef)?.offsetHeight === 0) {
|
return new Promise((resolve) => {
|
||||||
useTimeoutFn(() => {
|
if (unref(elRef)?.offsetHeight === 0) {
|
||||||
setOptions(unref(getOptions));
|
useTimeoutFn(() => {
|
||||||
}, 30);
|
setOptions(unref(getOptions));
|
||||||
return;
|
resolve(null);
|
||||||
}
|
}, 30);
|
||||||
nextTick(() => {
|
}
|
||||||
useTimeoutFn(() => {
|
nextTick(() => {
|
||||||
if (!chartInstance) {
|
useTimeoutFn(() => {
|
||||||
initCharts(getDarkMode.value as 'default');
|
if (!chartInstance) {
|
||||||
|
initCharts(getDarkMode.value as 'default');
|
||||||
|
|
||||||
if (!chartInstance) return;
|
if (!chartInstance) return;
|
||||||
}
|
}
|
||||||
clear && chartInstance?.clear();
|
clear && chartInstance?.clear();
|
||||||
|
|
||||||
chartInstance?.setOption(unref(getOptions));
|
chartInstance?.setOption(unref(getOptions));
|
||||||
}, 30);
|
resolve(null);
|
||||||
|
}, 30);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue