# 多个请求时的加载状态
/** Start: Loading */
const allLoading = reactive({
delData: false,
getTicketDashboard: false
});
const loading = ref(false);
const loadingTime = ref(new Date().getTime());
watch(() => allLoading, () => {
loading.value = true;
loadingTime.value = new Date().getTime();
debounceLoadingAnimation();
},{ deep: true });
function LoadingAnimation(){
setTimeout(() => {
loading.value = Object.values(allLoading).some(value => value === true);
}, Math.max(500 - ((new Date().getTime()) - loadingTime.value) / 1000), 0)
}
const debounceLoadingAnimation = debounce(LoadingAnimation,100);
/** Start: Loading */
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19