dashboard-progress-bar.vue 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. <template>
  2. <div class="demo-progress">
  3. <el-progress type="dashboard" :percentage="percentage" :color="colors" />
  4. <el-progress type="dashboard" :percentage="percentage2" :color="colors" />
  5. <div>
  6. <el-button-group>
  7. <el-button :icon="Minus" @click="decrease" />
  8. <el-button :icon="Plus" @click="increase" />
  9. </el-button-group>
  10. </div>
  11. </div>
  12. </template>
  13. <script lang="ts" setup>
  14. import { onMounted, ref } from 'vue'
  15. import { Minus, Plus } from '@element-plus/icons-vue'
  16. const percentage = ref(10)
  17. const percentage2 = ref(0)
  18. const colors = [
  19. { color: '#f56c6c', percentage: 20 },
  20. { color: '#e6a23c', percentage: 40 },
  21. { color: '#5cb87a', percentage: 60 },
  22. { color: '#1989fa', percentage: 80 },
  23. { color: '#6f7ad3', percentage: 100 },
  24. ]
  25. const increase = () => {
  26. percentage.value += 10
  27. if (percentage.value > 100) {
  28. percentage.value = 100
  29. }
  30. }
  31. const decrease = () => {
  32. percentage.value -= 10
  33. if (percentage.value < 0) {
  34. percentage.value = 0
  35. }
  36. }
  37. onMounted(() => {
  38. setInterval(() => {
  39. percentage2.value = (percentage2.value % 100) + 10
  40. }, 500)
  41. })
  42. </script>
  43. <style scoped>
  44. .demo-progress .el-progress--line {
  45. margin-bottom: 15px;
  46. width: 350px;
  47. }
  48. .demo-progress .el-progress--circle {
  49. margin-right: 15px;
  50. }
  51. </style>