环形进度条-带加载动画(Vue3+TS)

在这里插入图片描述

组件定义: CircleProgress.vue

<!-- 
 
  该组件,主要是解决环形进度条,可以实现动画加载的效果,
  如果没有动画效果,建议使用: https://element-plus.gitee.io/zh-CN/component/progress.html
 -->
<template>
  <div class="progress" :style="{ width, height }">
    <svg viewBox="0 0 96 96" class="svg-circle-progress" style="width: 96px; height: 96px">
      <circle
        r="40"
        cx="48"
        cy="48"
        fill="none"
        stroke-miterlimit="20"
        stroke-width="10"
        class="svg-progress"
        style="stroke-dasharray: 275, 279.602; stroke: #eee"
      ></circle>
      <circle
        r="40"
        cx="48"
        cy="48"
        fill="none"
        stroke-miterlimit="20"
        stroke-width="10"
        class="svg-progress"
        :style="`stroke-dasharray: ${progressValue}, 279.602;stroke:${color};`"
      ></circle>
    </svg>
    <div class="mask">
      <span class="bigData"> {{ showProgress }} </span> %
    </div>
  </div></template
>
<script setup lang="ts">
  import { ref, toRefs, watch, onMounted } from 'vue';

  const props = defineProps({
    targetValue: {
      type: Number,
      require: true,
      default: -1,
    },
    color: {
      type: String,
      default: '#4c7cee',
    },
    width: {
      type: String,
      default: '210px',
    },
    height: {
      type: String,
      default: '100px',
    },
  });
  const { height, width, color, targetValue } = toRefs(props);

  const showProgress = ref<number>(0);
  const addData = () => {
  	if(targetValue.value === 0) return;
    let timer = setInterval(() => {
      if (targetValue.value === showProgress.value) {
        clearInterval(timer), timer == null;
        return;
      }
      ++showProgress.value;
    }, 15);
  };
  onMounted(() => {
    addData();
  });
  const progressValue = ref<number>((showProgress.value / 100) * 250);

  watch(showProgress, (newValue: number) => {
    progressValue.value = (newValue / 100) * 250;
  });
</script>
<style lang="less" scoped>
  .progress {
    display: inline-block;
    position: relative;
    height: 100px;
    text-align: center;
  }
  .svg-circle-progress {
    position: relative;
    transform: rotate(-90deg);
  }
  .svg-progress {
    stroke: #2196f3;
    stroke-linecap: round;
    transition: all 0.3s linear;
  }
  .mask {
    position: absolute;
    top: 50%;
    left: 23%;
    transform: translate(-50%, -50%);
    .bigData {
      font-size: 30px;
      font-weight: 500;
      color: #232323;
      margin-right: -5px;
    }
  }
</style>


使用:

<template>
  // other code....
  
 <div class="" style="margin: 50px 0">
	 <CircleProgress :target-value="progress1" />
	 <CircleProgress :target-value="progress2" />
	 <CircleProgress :target-value="progress3" />
 </div>
        
 // other code....
</template>

<script setup lang="ts">
 import CircleProgress from './CircleProgress.vue';

 // 数值需来源于后端接口
 const progress1 = 87;
 const progress2 = 45;
 const progress3 = 6;
	
</script>
引用: 在Vue页面中使用VueQuill的示例代码如下: ```html <quill-editor ref="myQuillEditor" v-model="value" toolbar="full" theme="snow" /> ``` 这段代码展示了如何在Vue页面中使用VueQuill编辑器组件,并设置了一些属性,如ref、v-model、toolbar和theme。 引用: VueQuill是一个用于构建富文本编辑器的Vue组件,它是对Quill编辑器的一个封装。它使得在Vue 3应用程序中更易于使用。 引用: 你可以使用包管理工具来下载VueQuill,例如npm或yarn。使用以下命令可以下载VueQuill: ``` npm install @vueup/vue-quill@beta --save ``` 或者 ``` yarn add @vueup/vue-quill@beta ``` 这些命令将安装VueQuill的beta版本并将其保存到你的项目中。 所以,如果你想在Vue 3项目中使用VueQuill编辑器,你可以按照上述步骤进行安装,并在你的Vue组件中使用VueQuill组件来实现富文本编辑功能。<span class="em">1</span><span class="em">2</span><span class="em">3</span> #### 引用[.reference_title] - *1* *3* [Vue3适用的富文本编辑器(vue2.0 vue-quill-editor)](https://blog.csdn.net/weixin_55609002/article/details/126339278)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_2"}}] [.reference_item style="max-width: 50%"] - *2* [vue-quill:Vue 3组件的笔管编辑器](https://download.csdn.net/download/weixin_42114046/16013971)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_2"}}] [.reference_item style="max-width: 50%"] [ .reference_list ]
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值