ny
23 小时以前 282fbc6488f4e8ceb5fda759f963ee88fbf7b999
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
import type { ComputedRef } from 'vue';
 
import type { BasicTableProps } from '../types/table';
 
import { computed, ref, unref, watch } from 'vue';
 
export function useLoading(props: ComputedRef<BasicTableProps>) {
  const loadingRef = ref(unref(props).loading);
 
  watch(
    () => unref(props).loading,
    (loading) => {
      loadingRef.value = loading;
    },
  );
 
  const getLoading = computed(() => unref(loadingRef));
 
  function setLoading(loading: boolean) {
    loadingRef.value = loading;
  }
 
  return { getLoading, setLoading };
}