matters needing attention:
viewBox fill canvas;
:stroke-dasharray Perimeter;
:stroke-dashoffset Proportion of non transparency;
Expand|Select|Wrap|Line Numbers
- <svg :width="size"
- :height="size"
- viewBox="0 0 100 100">
- <!-- bgc -->
- <circle r="50" cx="50" cy="50"
- fill="transparent"
- ref="pbgc"
- class="progress-bgc"></circle>
- <!-- bar -->
- <circle r="50" cx="50" cy="50"
- fill="transparent"
- ref="pbar"
- :stroke-dasharray="dashArray"
- :stroke-dashoffset="dashOffset"
- class="progress-bar"></circle>
- </svg>
matters needing attention:
Transform-origin Operate by Center;
Transform:route(-90deg) Rotate 90°CCW;
Expand|Select|Wrap|Line Numbers
- circle {
- stroke-width: 6px;
- transform-origin: center;
- }
- .progress-bgc {
- transform: scale(0.9);
- /*stroke: rgba(66, 66, 66, 0.5);*/
- }
- .progress-bar {
- /*stroke: rgb(66, 66, 66);*/
- transform: rotate(-90deg) scale(0.9);
- }
The following is the property value passed in through the tag setting property:
Expand|Select|Wrap|Line Numbers
- size: {
- type: Number,
- default: 100
- },
- percent:{
- type:Number,
- default:0
- },
Expand|Select|Wrap|Line Numbers
- data(){
- return{
- dashArray:Math.PI * 2 * 50
- }
- },
- computed:{
- dashOffset(){
- return (1 - this.percent) * this.dashArray // clockwise,it is necessary to take the anti operation
- }
- }