mirror of
https://github.com/ecomfe/vue-echarts.git
synced 2025-11-07 05:28:06 +08:00
feat: support ref for provide api
This commit is contained in:
@ -1,4 +1,4 @@
|
||||
import { inject, computed, Ref, watchEffect } from "vue-demi";
|
||||
import { inject, unref, computed, Ref, watchEffect } from "vue-demi";
|
||||
import { EChartsType } from "../types";
|
||||
|
||||
export const LOADING_OPTIONS_KEY = "ecLoadingOptions";
|
||||
@ -8,9 +8,11 @@ export function useLoading(
|
||||
loading: Ref<boolean>,
|
||||
loadingOptions?: Ref<object | undefined>
|
||||
): void {
|
||||
const defaultLoadingOptions = inject(LOADING_OPTIONS_KEY, {}) as object;
|
||||
const defaultLoadingOptions = inject(LOADING_OPTIONS_KEY, {}) as
|
||||
| object
|
||||
| Ref<object>;
|
||||
const realLoadingOptions = computed(() => ({
|
||||
...defaultLoadingOptions,
|
||||
...unref(defaultLoadingOptions),
|
||||
...loadingOptions?.value
|
||||
}));
|
||||
|
||||
|
||||
Reference in New Issue
Block a user