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