<template>
<div class="loading" :style="{height:loadingRadiusVal+'px',width:loadingRadiusVal+'px'}">
<div v-for="(dotNum, index) in dotNums" :key="index" :style="dotTransform(index, dotNums)">
<span :style="dotAimation(index, dotNums)"></span>
</div>
</div>
</template>

js

<script>
export default{
props:{
loadingRadiusVal: { type: Number, default: 100 },
dotRadiusVal: { type: Number, default: 20 },
dotColorVal: { type: String, default: '#f00' },
dotNums: { type: Number, default: 10 }
},
data(){
return{ }
},
methods:{
dotTransform(idx,dotNums){
let rad = 2 * Math.PI / dotNums * idx;
let dotX = Math.cos(rad) * (this.loadingRadiusVal / 2);
let dotY = Math.sin(rad) * (this.loadingRadiusVal / 2);
return { transform: `translate(${dotX}px,${dotY}px)`,height: this.dotRadiusVal+'px',width:this.dotRadiusVal+'px'};
},
dotAimation(idx,dotNums){
let delayTime = `${-1*(1+idx)*1/dotNums}s`;
return{
animationDelay:delayTime,
background:this.dotColorVal
}
}
}
}
</script>

css

<style>
div.loading{
position: relative;
margin: 0 auto;
font-size:;
border-radius: 50%;
transform-origin: 50%;
}
div.loading div{
position: absolute;
top: 50%;
left: 50%;
border-radius: 100%;
}
span{
display: block;
border-radius: 50%;
width: 100%;
height: 100%;
animation: ball 1s infinite ease-in-out;
}
@keyframes ball{
0%{
opacity:;
transform: scale(1);
}
20%{
opacity:;
}
80%{
opacity:;
transform: scale(0);
}
}
</style>

vue——loading组件的更多相关文章

  1. vue loading组件

    <!-- * * loadingGif组件--"数据请求中" * * 使用方法: * <loading-gif :show-loading="showLoad ...

  2. VUE移动端音乐APP学习【四】:scroll组件及loading组件开发

    scroll组件 制作scroll 组件,然后嵌套一个 DOM 节点,使得该节点就能够滚动.该组件中需要引入 BetterScroll 插件. scroll.vue: <template> ...

  3. Vue 封装的loading组件

    <template> <div class="loadEffect"> <span></span> <span>< ...

  4. 浅尝Vue.js组件(二)

    本篇目录: 插槽(Slot) 插槽内容 作用域 具名插槽 作用域插槽 独占默认插槽的缩写语法 解构插槽Prop 使用场景举例 动态插槽名 具名插槽缩写 动态组件&keep-alive 异步组件 ...

  5. 自定义vue全局组件use使用

    自定义一个全局Loading组件,并使用:总结目录:|-components |-loading |-index.js 导出组件,并且install |-loading.vue 定义Loading组件 ...

  6. vue封装组件的正确方式-封装类似elementui的组件

    最近读了下element的源码,仿照他封装了两种不同的组件. 第一种:通过组件来调用显示的 <template> <!--src/component/custom/main.vue- ...

  7. 自定义vue全局组件use使用(解释vue.use()的原理)

    我们在前面学习到是用别人的组件:Vue.use(VueRouter).Vue.use(Mint)等等.其实使用的这些都是全剧组件,这里我们就来讲解一下怎么样定义一个全局组件,并解释vue.use()的 ...

  8. vue2.0 仿手机新闻站(五)全局的 loading 组件

    1.组件结构 index.js const LoadingComponent = require('./Loading.vue') const loading = { install: functio ...

  9. [Loading Component]Loading组件的v-model设计是否不合理?

    vue在2.4.2版本中给computed里的属性加了限制,详见assigning to a computed property without setter does not fail 项目将vue ...

随机推荐

  1. c++学习之初话 函数指针和函数对象 的因缘

    函数指针可以方便我们调用函数,但采用函数对象,更能体现c++面向对象的程序特性. 函数对象的本质:()运算符的重载.我们通过一段代码来感受函数指针和函数对象的使用: int AddFunc(int a ...

  2. 布局无法发送,布局发布状态停留在“Transferring”,进度停留在 0%

    按顺序检查如下: 1. 检查Player是否在线?不在线则无法发送任何内容,进度会停留在0%,待Player下次在线时,任务自动开始传输. Player在线,Messenger上可以看到Player名 ...

  3. springboot 静态注入 单例

    package com.b2q.web_push.util; import io.goeasy.GoEasy; import org.springframework.beans.factory.ann ...

  4. git 回退各种场景操作

    在git的一般使用中,如果发现错误的将不想提交的文件add进入index之后,想回退取消,则可以使用命令:git reset HEAD <file>...,同时git add完毕之后,gi ...

  5. [模板] dp套dp && bzoj5336: [TJOI2018]party

    Description Problem 5336. -- [TJOI2018]party Solution 神奇的dp套dp... 考虑lcs的转移方程: \[ lcs[i][j]=\begin{ca ...

  6. this指针详解

    什么是this this是一个const指针,存的是当前对象的地址,指向当前对象,通过this指针可以访问类中的所有成员. 当前对象是指正在使用的对象,比如a.print(),a就是当前对象. 关于t ...

  7. opencv 增强现实(一):特征点检测

    import cv2 as cv import numpy as np def draw_keypoints(img, keypoints): for kp in keypoints: x, y = ...

  8. 用Pytorch训练线性回归模型

    假定我们要拟合的线性方程是:\(y=2x+1\) \(x\):[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14] \(y\):[1, 3, 5, 7, ...

  9. [powershell]解决Win7SP1 powershell底色变成黑色

    删除补丁KB3191566 重新安装: https://docs.microsoft.com/en-us/powershell/scripting/install/installing-windows ...

  10. Spring security oauth2 client_credentials认证 最简单示例代码

    基于spring-boot-2.0.0 1,在pom.xml中添加: <!-- security --> <!-- https://mvnrepository.com/artifac ...