Files
qnc-admin-v3/docs/src/guide/in-depth/loading.md
liangzai 69f3c4ce45
Some checks failed
CI / Test (ubuntu-latest) (push) Has been cancelled
CI / Test (windows-latest) (push) Has been cancelled
CI / Lint (ubuntu-latest) (push) Has been cancelled
CI / Lint (windows-latest) (push) Has been cancelled
CI / Check (ubuntu-latest) (push) Has been cancelled
CI / Check (windows-latest) (push) Has been cancelled
CodeQL / Analyze (javascript-typescript) (push) Has been cancelled
Deploy Website on push / Deploy Push Playground Ftp (push) Has been cancelled
Deploy Website on push / Deploy Push Docs Ftp (push) Has been cancelled
Deploy Website on push / Deploy Push Antd Ftp (push) Has been cancelled
Deploy Website on push / Deploy Push Element Ftp (push) Has been cancelled
Deploy Website on push / Deploy Push Naive Ftp (push) Has been cancelled
Release Drafter / update_release_draft (push) Has been cancelled
CI / CI OK (push) Has been cancelled
Deploy Website on push / Rerun on failure (push) Has been cancelled
Lock Threads / action (push) Has been cancelled
Issue Close Require / close-issues (push) Has been cancelled
Close stale issues / stale (push) Has been cancelled
f
2026-01-10 18:11:29 +08:00

1.2 KiB
Raw Blame History

全局loading

全局 loading 指的是页面刷新时出现的加载效果,通常是一个旋转的图标:

Global loading spinner

原理

vite-plugin-inject-app-loading 插件实现,插件会在每个应用都注入一个全局的 loading html

关闭

如果你不需要全局 loading可以在 .env 文件中关闭:

VITE_INJECT_APP_LOADING=false

自定义

如果你想要自定义全局 loading可以在应用目录下index.html同级,创建一个loading.html文件插件会自动读取并注入。这个html可以自行定义样式和动画。

::: tip

  • 你可以使用跟index.html一样的语法,比如VITE_APP_TITLE变量,来获取应用的标题。
  • 必须保证有一个id="__app-loading__"的元素。
  • id="__app-loading__"的元素,加一个 hidden class。
  • 必须保证有一个style[data-app-loading="inject-css"]的元素。
<style data-app-loading="inject-css">
  #__app-loading__.hidden {
    pointer-events: none;
    visibility: hidden;
    opacity: 0;
    transition: all 1s ease-out;
  }
  /* ... */
</style>
<div id="__app-loading__">
  <!-- ... -->
  <div class="title"><%= VITE_APP_TITLE %></div>
</div>

:::