因为有很多组件需要loading,所以我们把loading写为组件,在全局中都可以使用
而选择的loading ,最好是css3动画写的,如果用图片,图片本身就是需要请求的
在网上找了一个css3动画,如下:
loading中的代码:
<template>
<div class="loader"></div>
</template>
<script>
export default {};
</script>
<style scoped>
.loader {
position: relative;
width: 2.5em;
height: 2.5em;
transform: rotate(165deg);
}
.loader:before,
.loader:after {
content: "";
position: absolute;
top: 50%;
left: 50%;
display: block;
width: 0.5em;
height: 0.5em;
border-radius: 0.25em;
transform: translate(-50%, -50%);
}
.loader:before {
animation: before 2s infinite;
}
.loader:after {
animation: after 2s infinite;
}
@keyframes before {
0% {
width: 0.5em;
box-shadow: 1em -0.5em rgba(225, 20, 98, 0.75),
-1em 0.5em