效果如下图:
自定义传入宽度和当前进度(0~100)
?①创建进度条组件Progress.vue:
<template>
<div class="m-progress" :style="`width:${width}px;`">
<div class="m-progress-outer">
<div class="m-progress-inner">
<div class="u-progress-bg" :style="`width: ${progress}%;`"></div>
</div>
</div>
<span class="u-progress-text">{{ progress }}%</span>
</div>
</template>
<script>
export default {
name: 'Progress',
props: {
title: { // 标题
type: String,
default: '温馨提示'
},
width: {
type: Number,
default: 600
},
progress: {
type: Number,
default: 36
}
},
methods: {
}
}
</script>
<style lang="less" scoped>
.m-progress {
color: rgba(0,0,0,.65);
font-size: 16px;
line-height: 24px;
margin: 30px auto;
.m-progress-outer {
display: inline-block;
width: calc(100% - 60px);
.m-progress-inner {
width: 100%;
background-color: #f5f5f5;
border-radius: 100px;
.u-progress-bg {
background-color: #1890ff;
border-radius: 100px;
height: 8px;
transition: all .3s cubic-bezier(.08,.82,.17,1) 0s;
}
}
}
.u-progress-text {
margin-left: 10px;
width: 50px;
color: rgba(0,0,0,.45);
text-align: left;
vertical-align: middle;
}
}
</style>
②在要使用的页面引入:
<Progress :width="600" :progress="36"/>
import Progress from '@/components/Progress'
components: {
Progress
}
|