ProjressCircle.vue



<template>
<div class="progress-circle">
<svg :width="size" :height="size" viewBox="0 0 100 100">
<circle r="50" cx="50" cy="50" fill="transparent" class="progress-background"></circle>
<circle r="50" cx="50" cy="50" fill="transparent" class="progress-bar" :stroke-dasharray="dashArray" :stroke-dashoffset="dashOffset"></circle>
</svg>
</div>
</template>

<script>
export default {
props: {
size: { type: Number, default: 100 },
percent: { type: Number, default: 0 }
},
data() {
return { dashArray: Math.PI * 2 * 50 }
},
computed: {
dashOffset() {
return (1 - this.percent) * this.dashArray
}
}
}
</script>

<style scoped>
circle {
stroke-width: 10px;
transform-origin: center;
}
.progress-background {
transform: scale(0.9);
stroke: rgba(66, 66, 66, 0.5);
}
.progress-bar {
stroke: greenyellow;
transform: rotate(-90deg) scale(0.9);
}
</style>


使用:



<ProjressCircle :size="100" :percent="0.2"></ProjressCircle>


效果:

环形进度条_环形进度条