<template>
<div>
<div class="Progress">
<div class="jindu" :style="{ width: jindu + '%' }"></div>
</div>
<div class="Progress-button">
<el-button @click="start()" type="primary" plain>开始</el-button>
<el-button @click="stop()" type="primary" plain>停止</el-button>
</div>
</div>
</template>
<script>
export default {
data() {
return {
jindu: 0,
};
},
created() {},
mounted() {},
methods: {
progress(data) {
let _this = this;
_this.clearInt = setInterval(function () {
if (_this.jindu < data) {
_this.jindu++;
} else {
clearInterval(_this.clearInt);
}
}, 100);
},
start() {
this.progress(100);
},
stop() {
// var num = Math.floor(Math.random() * 40 + 50);
clearInterval(this.clearInt);
},
},
};
</script>
<style lang="less" scoped>
.Progress {
height: 30px;
margin: 0 auto;
margin-top: 50px;
border-radius: 100px;
background-color: #ebeef5;
.jindu {
background-color: #409eff;
border-radius: 100px;
height: 100%;
overflow: hidden;
}
}
.Progress-button {
margin-top: 20px;
}
</style>