管理系统——应用初始化 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')

动画效果

相关推荐
打小就很皮...15 小时前
基于 Dify 实现 AI 流式对话:组件设计思路(React)
前端·react.js·dify·流式对话
这个昵称也不能用吗?15 小时前
【安卓 - 小组件 - app进程与桌面进程】
前端
kuilaurence15 小时前
CSS `border-image` 给文字加可拉伸边框
前端·css
一 乐15 小时前
校园墙|校园社区|基于Java+vue的校园墙小程序系统(源码+数据库+文档)
java·前端·数据库·vue.js·spring boot·后端·小程序
一只小阿乐15 小时前
前端react 开发 图书列表分页
前端·react.js·react·ant-
IT古董15 小时前
在 React 项目中使用 Ky 与 TanStack Query 构建现代化数据请求层
前端·react.js·前端框架
夏日不想说话15 小时前
一文搞懂 AI 流式响应
前端·node.js·openai
顾安r16 小时前
11.14 脚本网页 青蛙过河
服务器·前端·python·游戏·html
不爱吃糖的程序媛17 小时前
Electron 智能文件分析器开发实战适配鸿蒙
前端·javascript·electron
Doro再努力17 小时前
2025_11_14洛谷【入门1】数据结构刷题小结
前端·数据结构·算法