vue项目全局loading怎么加

411 阅读1分钟

参考了若依官网和一个vue3后台管理系统模板 他们的功能都非常强大

1718348263025.png

vue.ruoyi.vip/login?redir…

`<!DOCTYPE html>  
<html lang="en">  
<head>  
<meta charset="UTF-8" />  
<link rel="icon" href="/favicon.ico" />  
<meta name="viewport" content="width=device-width, initial-scale=1.0" />  
<title>TDesign Vue Next Starter</title>  
</head>  
<body>  
<div id="app">  
<div class="loader"></div>  
</div>  
<script type="module" src="/src/main.ts"></script>  
<script>  
</script>  
</body>  
  
<script>  
window.global = window;  
</script>  
  
<style>  
.loader {  
position: fixed;  
top: 50%;  
left: 50%;  
width: 40px;  
aspect-ratio: 0.577;  
overflow: hidden;  
clip-path: polygon(0 0, 100% 100%, 0 100%, 100% 0);  
animation: l19 2s infinite linear;  
}  
  
.loader::before {  
position: absolute;  
inset: -150%;  
content: "";  
background: repeating-conic-gradient(  
from 30deg,  
#ffabab 0 60deg,  
#abe4ff 0 120deg,  
#ff7373 0 180deg  
);  
animation: inherit;  
animation-direction: reverse;  
}  
  
@keyframes l19 {  
100% {  
transform: rotate(360deg);  
}  
}  
</style>  
</html>`

其实只要找到vue项目根目录的index.html页面加入一个 <div class="loader"></div> 再写写动画样式就ok了

具体原理我还不知道是啥 反正简单好用