shop_uniapp/components/cu-progress/cu-progress.vue

70 lines
1.2 KiB
Vue
Raw Permalink Normal View History

2024-06-06 09:55:01 +08:00
<template>
2024-06-20 02:45:12 +08:00
<view class="cu-progress"
:style="'height: ' + progressHeight + '; width: ' + progressWidth + ';background-color: ' + progressColor">
<view class="cu-progress-bar"
:style="'background-color: ' + progressBarColor + ';left: ' + barLeft + 'rpx; width:' + barWidth + 'rpx'">
</view>
</view>
2024-06-06 09:55:01 +08:00
</template>
<script>
2024-06-20 02:45:12 +08:00
export default {
data() {
return {
currentSwiper: 0,
offset: 0,
barLeft: 0
};
},
props: {
progressBarColor: {
type: String,
default: '#01B55B'
},
progressWidth: {
type: Number,
default: 90
},
progressHeight: {
type: Number,
default: 6
},
progressColor: {
type: String,
default: '#E5E5E5'
},
left: {
type: Number,
default: 0
},
barWidth: {
type: Number,
default: 30
}
},
watch: {
'left': function(value) {
this.barLeft = value / 100 * this.offset
}
},
2024-06-06 09:55:01 +08:00
2024-06-20 02:45:12 +08:00
beforeMount: function() {
this.offset = this.progressWidth - this.barWidth
},
};
2024-06-06 09:55:01 +08:00
</script>
<style>
2024-06-20 02:45:12 +08:00
.cu-progress {
background-color: #E5E5E5;
height: 6rpx;
width: 90rpx;
position: relative;
}
2024-06-06 09:55:01 +08:00
2024-06-20 02:45:12 +08:00
.cu-progress .cu-progress-bar {
height: 100%;
width: 30rpx;
position: absolute;
left: 0;
}
2024-06-06 09:55:01 +08:00
</style>