Commit 26d9476caff41cc355190604af42e0bd2ef0a353
1 parent
ddd1893b
feat(use-loading): add `setTip` method
为useLoading添加setTip方法
Showing
2 changed files
with
11 additions
and
4 deletions
CHANGELOG.zh_CN.md
src/components/Loading/src/useLoading.ts
@@ -12,10 +12,12 @@ interface Fn { | @@ -12,10 +12,12 @@ interface Fn { | ||
12 | (): void; | 12 | (): void; |
13 | } | 13 | } |
14 | 14 | ||
15 | -export function useLoading(props: Partial<LoadingProps>): [Fn, Fn]; | ||
16 | -export function useLoading(opt: Partial<UseLoadingOptions>): [Fn, Fn]; | 15 | +export function useLoading(props: Partial<LoadingProps>): [Fn, Fn, (string) => void]; |
16 | +export function useLoading(opt: Partial<UseLoadingOptions>): [Fn, Fn, (string) => void]; | ||
17 | 17 | ||
18 | -export function useLoading(opt: Partial<LoadingProps> | Partial<UseLoadingOptions>): [Fn, Fn] { | 18 | +export function useLoading( |
19 | + opt: Partial<LoadingProps> | Partial<UseLoadingOptions> | ||
20 | +): [Fn, Fn, (string) => void] { | ||
19 | let props: Partial<LoadingProps>; | 21 | let props: Partial<LoadingProps>; |
20 | let target: HTMLElement | Ref<ElRef> = document.body; | 22 | let target: HTMLElement | Ref<ElRef> = document.body; |
21 | 23 | ||
@@ -39,5 +41,9 @@ export function useLoading(opt: Partial<LoadingProps> | Partial<UseLoadingOption | @@ -39,5 +41,9 @@ export function useLoading(opt: Partial<LoadingProps> | Partial<UseLoadingOption | ||
39 | instance.close(); | 41 | instance.close(); |
40 | }; | 42 | }; |
41 | 43 | ||
42 | - return [open, close]; | 44 | + const setTip = (tip: string) => { |
45 | + instance.setTip(tip); | ||
46 | + }; | ||
47 | + | ||
48 | + return [open, close, setTip]; | ||
43 | } | 49 | } |