I want to use a bootstrap 5 progress bar to show the remaning time of a countdown. I've created the needed markup in my vuejs component template
<div class="progress">
<div class="progress-bar" ref="elaspedTime" role="progressbar" aria-valuenow="0" aria-valuemin="0" aria-valuemax="100">
{{ minutes }} seconds
</div>
</div>
In my methods I have this two functions, one is for starting the countdown and the other to stop it when the minutes reach the zero.
startTimer(){
this.$refs.elaspedTime.width = '0%';
this.countdown = setInterval( () => {
this.minutes--;
if( this.$refs.elaspedTime.width < '100%' ){
this.$refs.elaspedTime.width += '0.6%';
}
if( this.minutes === 0 ){
this.stopTimer();
}
},1000);
},
stopTimer(){
clearInterval(this.countdown);
}
How I can change the progress bar width until it reach the 100% according to the countdown minutes elasped?