<template>
<div>
? <el-progress :percentage="nuw" color="#8e71c7"></el-progress>
? <button @click="click"> 下一步 </button>
</div>
</template>
data(){
? return {
? ? ? ? ? nuw:0,
}
},
methods: {
? click(){
? ? //定義定時器開始時間為0
? ? var progressnuw =0;
? ? //頂一個定時器
? ? var timer=setInterval(()=>{
? ? ? //變量一直++
? ? ? progressnuw++
? ? ? //清楚定時器
? ? ? if(progressnuw>=100){
? ? ? ? clearInterval(timer);
}
? ? ? //獲取重新賦值
? ? ? this.nuw=progressnuw
? ? },30)
}
},