Toggle navigation
Toggle navigation
This project
Loading...
Sign in
Hooke
/
stdj_h5
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Graphs
Network
Create a new issue
Commits
Issue Boards
Authored by
hookehuyr
2025-11-04 21:32:42 +0800
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
d04059ae67c5c186d26b6c8a276966ec3b8f1ed3
d04059ae
1 parent
d16e0afa
feat(路由): 添加路由懒加载时的加载状态占位
使用Suspense组件包裹路由视图,在懒加载时显示加载动画,避免白屏现象
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
13 additions
and
2 deletions
src/App.vue
src/App.vue
View file @
d04059a
...
...
@@ -7,8 +7,19 @@
-->
<template>
<div id="app">
<router-view />
<!-- 全局loading蒙版 -->
<!-- 路由懒加载时的占位,避免白屏 -->
<router-view v-slot="{ Component }">
<Suspense>
<component :is="Component" />
<template #fallback>
<div class="global-loading-overlay">
<van-loading type="spinner" size="24px" color="#FFF" text-color="#FFF">加载中...</van-loading>
</div>
</template>
</Suspense>
</router-view>
<!-- 全局loading蒙版(接口进行中显示) -->
<div v-if="is_loading" class="global-loading-overlay">
<van-loading type="spinner" size="24px" color="#FFF" text-color="#FFF">加载中...</van-loading>
</div>
...
...
Please
register
or
login
to post a comment