vue3+ts+vite项目页面初始化loading加载效果

简介

一分钟实现 vue-pure-admin 同款项目加载时的 loading 效果

一、先看效果

1.1 静态效果

vue3+ts+vite项目页面初始化loading加载效果_第1张图片

1.2 动态效果

vue3+ts+vite项目页面初始化loading加载效果_第2张图片

二、上代码

核心代码在body里面,代码中已标明。找到你项目的 index.html ,复制粘贴进去即可

<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" />
    <meta name="renderer" content="webkit" />
    <meta
      name="viewport"
      content="width=device-width,initial-scale=1.0,minimum-scale=1.0,maximum-scale=1.0,user-scalable=0"
    />
    <title>vue-pure-admin</title>
    <link rel="icon" href="/favicon.ico" />
    <script>
      window.process = {};
    </script>
  </head>

  <body>
    // 核心代码-开始
    <div id="app">
      <style>
        html,
        body,
        #app {
          width: 100%;
          height: 100%;
          display: flex;
          position: relative;
          justify-content: center;
          align-items: center;
          overflow: hidden;
        }

        .loader,
        .loader:before,
        .loader:after {
          border-radius: 50%;
          width: 2.5em;
          height: 2.5em;
          animation-fill-mode: both;
          animation: loadAnimation 1.8s infinite ease-in-out;
        }

        .loader {
          color: #406eeb;
          font-size: 10px;
          margin: 80px auto;
          position: relative;
          text-indent: -9999em;
          transform: translateZ(0);
          animation-delay: -0.16s;
          top: 0;
          transform: translate(-50%, 0);
        }

        .loader:before,
        .loader:after {
          content: "";
          position: absolute;
          top: 0;
        }

        .loader:before {
          left: -3.5em;
          animation-delay: -0.32s;
        }

        .loader:after {
          left: 3.5em;
        }

        @keyframes loadAnimation {
          0%,
          80%,
          100% {
            box-shadow: 0 2.5em 0 -1.3em;
          }

          40% {
            box-shadow: 0 2.5em 0 0;
          }
        }
      </style>
      <div class="loader"></div>
    </div>
    // 核心代码-结束
    <script type="module" src="/src/main.ts"></script>
  </body>
</html>

你可能感兴趣的:(#,Vue3从零到一项目实战,javascript,前端,vue.js)