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

动画效果

相关推荐
梦帮科技1 小时前
Node.js配置生成器CLI工具开发实战
前端·人工智能·windows·前端框架·node.js·json
VT.馒头1 小时前
【力扣】2695. 包装数组
前端·javascript·算法·leetcode·职场和发展·typescript
css趣多多2 小时前
一个UI内置组件el-scrollbar
前端·javascript·vue.js
C澒2 小时前
前端整洁架构(Clean Architecture)实战解析:从理论到 Todo 项目落地
前端·架构·系统架构·前端框架
C澒2 小时前
Remesh 框架详解:基于 CQRS 的前端领域驱动设计方案
前端·架构·前端框架·状态模式
Charlie_lll2 小时前
学习Three.js–雪花
前端·three.js
onebyte8bits2 小时前
前端国际化(i18n)体系设计与工程化落地
前端·国际化·i18n·工程化
C澒3 小时前
前端分层架构实战:DDD 与 Clean Architecture 在大型业务系统中的落地路径与项目实践
前端·架构·系统架构·前端框架
BestSongC3 小时前
行人摔倒检测系统 - 前端文档(1)
前端·人工智能·目标检测
0思必得03 小时前
[Web自动化] Selenium处理滚动条
前端·爬虫·python·selenium·自动化