管理系统——应用初始化 Loading 动画

动画创建

  • 位置:index.html
js 复制代码
  <div id="app">
      ... 动画内容 ...
  </div>
  <script type="module" src="/src/main.js"></script>

动画消失

/src/main.js 加载完毕之后,createApp(App).mount('#app') 会替换掉 #app 内的内容。

js 复制代码
import { createApp } from 'vue'
import './style.css'
import App from './App.vue'

createApp(App).mount('#app')

完整代码

  • index.html
html 复制代码
<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8" />
  <link rel="icon" type="image/svg+xml" href="/vite.svg" />
  <meta name="viewport" content="width=device-width, initial-scale=1.0" />
  <title>我的网站</title>
</head>

<body>
  <div id="app">
    <style>
      * {
        /* 初始化 取消页面内外边距 */
        margin: 0;
        padding: 0;
      }

      body {
        /* 100%窗口高度 */
        height: 100vh;
        background: linear-gradient(to bottom, #2b5876, #09203f);
        /* 弹性布局 水平、垂直居中 */
        display: flex;
        justify-content: center;
        align-items: center;
      }

      .loading {
        width: 200px;
        height: 200px;
        box-sizing: border-box;
        border-radius: 50%;
        border-top: 10px solid #63A69F;
        /* 相对定位 */
        position: relative;
        /* 执行动画:动画a1 时长 线性的 无限次播放 */
        animation: a1 2s linear infinite;
      }

      .loading::before,
      .loading::after {
        content: "";
        width: 200px;
        height: 200px;
        /* 绝对定位 */
        position: absolute;
        left: 0;
        top: -10px;
        box-sizing: border-box;
        border-radius: 50%;
      }

      .loading::before {
        border-top: 10px solid #F2E1AC;
        /* 旋转120度 */
        transform: rotate(120deg);
      }

      .loading::after {
        border-top: 10px solid #F2836B;
        /* 旋转240度 */
        transform: rotate(240deg);
      }

      .loading span {
        /* 绝对定位 */
        position: absolute;
        width: 200px;
        height: 200px;
        line-height: 200px;
        text-align: center;
        color: #fff;
        /* 执行动画:动画a2 时长 线性的 无限次播放 */
        animation: a2 2s linear infinite;
      }
      /* 定义动画 */
      @keyframes a1 {
        to {
          transform: rotate(360deg);
        }
      }
      @keyframes a2 {
        to {
          transform: rotate(-360deg);
        }
      }
    </style>
    <div class="loading">
      <span>拼命加载中</span>
    </div>
  </div>
  <script type="module" src="/src/main.js"></script>
</body>
</html>
  • main.js
js 复制代码
import { createApp } from 'vue'
import './style.css'
import App from './App.vue'

createApp(App).mount('#app')

动画效果

相关推荐
Dxy12393102166 分钟前
JS如何把数据添加到列表中
前端·javascript·vue.js
蜡台11 分钟前
Uniapp 实现 二手车价格评估 功能
前端·javascript·uni-app·估值·汽车抵押·二手车评估
旭久13 分钟前
web前端开发好物推荐-(code-inspector-plugin/react-dev-inspector)页面快捷定位代码位置
前端·react.js·前端框架
floret. 小花16 分钟前
Vue3 知识点总结 · 2026-03-20
前端·面试·electron·学习笔记·vue3
木斯佳18 分钟前
前端八股文面经大全:Bilibili 前端实习面(2026-03-20)·深度解析
前端·sse·ssr·rag
比特森林探险记20 分钟前
Element Plus 实战指南
前端·javascript
Fairy要carry27 分钟前
面试-Dispatch Tools
前端·chrome
IT_陈寒27 分钟前
JavaScript开发者必看:3个让代码效率翻倍的隐藏技巧
前端·人工智能·后端
嘉琪00130 分钟前
Day8 完整学习包(Vue 基础 & 响应式)——2026 0320
前端·vue.js·学习
FlyWIHTSKY31 分钟前
Vue3 单文件中不同的组件
前端·javascript·vue.js