用vue做一個動態的環形進度條

1.給項目安裝一個組件:vue-circleprogressbar

npm install vue-circleprogressbar

2.項目引用
動態改變進度數據;

<template> 
	 <div class="wrap-progress" style="height: 200px;">
	        <circle-progressbar 
	        	:id="1" 
	        	barColor="#0000ff" 
	         	backgroundColor="rgba(0,0,0,0.4)" 
	        	:width="100" 
	        	:radius="10" 
	        	:progress="progress"
	          :isAnimation="false"></circle-progressbar>
	      </div>
</template>

<script>
 import circleProgressbar from 'vue-circleprogressbar';
  export default { 
	//組件引用
    components: {
      circleProgressbar
    },
    data(){
    	return {
			progress: 0,
		}
    },
    created() {
     this.progress = 0;
        var that = this;
        var timer = setInterval(function () {
          that.progress = parseInt(that.progress) + 10;
          // console.log(that.progress);
          if (that.progress == 100) {
            if (that.progress == "100") {
              that.dialogComputedVisible = false;
            }
            clearInterval(timer);
          }
        }, 1000);  
    },
}
</script>

參考文章
https://segmentfault.com/a/1190000016591047

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章