@fe6/water-pro
Version:
An enterprise-class UI design language and Vue-based implementation
26 lines (19 loc) • 547 B
text/typescript
/** @format */
import { ref, ComputedRef, unref, computed, watch } from 'vue';
import type { TableProProps } from '../types/table';
export function useLoading(props: ComputedRef<TableProProps>) {
const loadingRef = ref(unref(props).loading);
watch(
() => unref(props).loading,
(loading) => {
loadingRef.value = loading;
},
);
const getLoading = computed(() => {
return unref(loadingRef);
});
function setLoading(loading: boolean) {
loadingRef.value = loading;
}
return { getLoading, setLoading };
}