Commit 26d9476caff41cc355190604af42e0bd2ef0a353

Authored by 无木
1 parent ddd1893b

feat(use-loading): add `setTip` method

为useLoading添加setTip方法
CHANGELOG.zh_CN.md
... ... @@ -2,6 +2,7 @@
2 2  
3 3 - **Preview** 添加新的属性及事件
4 4 - **Dark Theme** 新增对 tailwindcss 夜间模式的支持
  5 +- **其它** 为 useLoading 添加 setTip 方法
5 6  
6 7 ### 🐛 Bug Fixes
7 8  
... ...
src/components/Loading/src/useLoading.ts
... ... @@ -12,10 +12,12 @@ interface Fn {
12 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 21 let props: Partial<LoadingProps>;
20 22 let target: HTMLElement | Ref<ElRef> = document.body;
21 23  
... ... @@ -39,5 +41,9 @@ export function useLoading(opt: Partial&lt;LoadingProps&gt; | Partial&lt;UseLoadingOption
39 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 }
... ...