vue首屏加载动画打包后失效
2024-05-28 10:44:21
今天早上在公司遇到一个奇怪的问题
再开发环境,正常运行使用的css加载动画,打包更新后消失了!!!
修改了N中加载动画控制的方式,包括再APP.vue中通过docoment控制元素显示隐藏,都没有效果…
好好好,开始查询loading打包问题,慢慢发现问题是通过build后产生的,
再vue-loader.conf.js文件中尝试修改:extract: false 后我成功了~~
附上截图:
我的加载动画示例:
(直接复制进去可用)
index.html中
<link rel="stylesheet" href="static/css/loading.css" />
<body> <div id="app"> <div id="appLoading"> <div class=loading-box> <div class=loading-wrap><span class="dot dot-spin"><i></i><i></i><i></i><i></i></span></div> </div> </div> </div> <!-- built files will be auto injected --> </body>
静态文件下添加loading.css
#appLoading {
width: 100%;
height: 100%;
padding: 0;
margin: 0;
position: absolute;
z-index: 999;
}
.loading-box {
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
width: 100%;
height: 100%;
}
.loading-box .loading-wrap {
display: flex;
align-items: center;
justify-content: center;
padding: 98px;
}
.dot {
position: relative;
box-sizing: border-box;
display: inline-block;
width: 32px;
height: 32px;
font-size: 32px;
transform: rotate(45deg);
animation: ant-rotate 1.2s infinite linear;
}
.dot i {
position: absolute;
display: block;
width: 14px;
height: 14px;
background-color: #1890ff;
border-radius: 100%;
opacity: 0.3;
transform: scale(0.75);
transform-origin: 50% 50%;
animation: ant-spin-move 1s infinite linear alternate;
}
.dot i:nth-child(1) {
top: 0;
left: 0;
}
.dot i:nth-child(2) {
top: 0;
right: 0;
animation-delay: 0.4s;
}
.dot i:nth-child(3) {
right: 0;
bottom: 0;
animation-delay: 0.8s;
}
.dot i:nth-child(4) {
bottom: 0;
left: 0;
animation-delay: 1.2s;
}
@keyframes ant-rotate {
to {
transform: rotate(405deg);
}
}
@keyframes ant-spin-move {
to {
opacity: 1;
}
}
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 全程不用写代码,我用AI程序员写了一个飞机大战
· MongoDB 8.0这个新功能碉堡了,比商业数据库还牛
· 记一次.NET内存居高不下排查解决与启示
· 白话解读 Dapr 1.15:你的「微服务管家」又秀新绝活了
· DeepSeek 开源周回顾「GitHub 热点速览」