uniapp-app/pages/loading/loading.vue
2026-02-02 17:44:10 +08:00

52 lines
958 B
Vue

<template>
<navBar :showLeft="false" :title="'加载中...'"></navBar>
<view class="loading-page"></view>
</template>
<script setup>
import { onMounted,ref} from 'vue';
import { onLoad,onUnload,onHide,onShow } from '@dcloudio/uni-app';
import navBar from '@/components/navBar/navBar.vue';
const timer=ref(null);
const count=ref(0);
const countDown=()=>{
if(timer.value){
return
}
timer.value=setInterval(()=>{
count.value++;
if(count.value>=3){
clearInterval(timer.value);
plus.runtime.quit();
}
},1000);
}
onShow(() => {
uni.showLoading({
title: '加载中...',
mask: true
});
countDown()
});
onUnload(() => {
uni.hideLoading();
if(timer.value){
clearInterval(timer.value);
}
});
onHide(() => {
uni.hideLoading();
if(timer.value){
clearInterval(timer.value);
}
});
</script>
<style scoped lang="scss">
.loading-page{
width: 100%;
height: 100%;
background: #fff;
}
</style>