vue项目之手写loading组件

loading组件

在这里插入图片描述
这是loading的效果。。。
直接上代码吧

<template>
  <div class="v-spinner" v-show="loading">
    <div class="v-dot-container">
      <div class="v-dot v-dot1" v-bind:style="spinnerBasicStyle">
        <div class="v-dot v-dot2" v-bind:style="spinnerStyle"></div>
        <div class="v-dot v-dot3" v-bind:style="spinnerStyle"></div>
        <div class="v-dot v-dot4" v-bind:style="spinnerStyle"></div>
        <div class="v-dot v-dot5" v-bind:style="spinnerStyle"></div>
      </div>
    </div>
  </div>
</template>

<script>
export default {
  name: "DotLoader",
  props: {
    loading: {
      type: Boolean,
      default: true,
    },
    size: {
      type: String,
      default: "60px",
    },
    margin: {
      type: String,
      default: "2px",
    },
    radius: {
      type: String,
      default: "100%",
    },
  },
  computed: {
    spinnerStyle() {
      return {
        height: parseFloat(this.size) / 3 + "px",
        width: parseFloat(this.size) / 3 + "px",
        borderRadius: this.radius,
        display:'inline-block'
      };
    },
    spinnerBasicStyle() {
      return {
        height: '46px',
        width: '46px',
        position: "relative",

      };
    },
  },
};
</script>

<style>
.v-spinner{
  position: relative;
  width: 100%;
  height: 100%;
  background: rgba(255, 255, 255, 0.7);
}
.v-dot-container{
  width: 46px;
  height: 46px;
  position: absolute;
  left: 0;
  top: 0;
  right: 0;
  bottom: 0;
  margin: auto;
}
.v-spinner .v-dot1 {
  -webkit-animation: v-dotRotate 2s 0s infinite linear;
  animation: v-dotRotate 2s 0s infinite linear;
  -webkit-animation-fill-mode: forwards;
  animation-fill-mode: forwards;
  
}

.v-dot2{
  margin-right: 4px;
  background-color:#f3717a ;
}
.v-dot3{
  background-color: #f1b3b9;
}
.v-dot4{
  margin-right: 4px;
  background-color: #f2acb2;
}
.v-dot5{
  background-color: #f1b3b9;
}

@-webkit-keyframes v-dotRotate {
  100% {
    -webkit-transform: rotate(360deg);
    transform: rotate(360deg);
  }
}
@keyframes v-dotRotate {
  100% {
    -webkit-transform: rotate(360deg);
    transform: rotate(360deg);
  }
}

</style>

有个vue插件库,其实我这个loading也是拿到别人的代码来改造的,放上链接,有需要的可以去看看哦
vue插件库:https://www.vue365.cn/

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值