index.vue 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. <template>
  2. <a-card :title="title" >
  3. <a-row justify="center">
  4. <a-col
  5. v-for="item in list"
  6. :key="item.key"
  7. :xs="12" :sm="12" :md="6" :lg="8" :xl="4"
  8. >
  9. <div class="statistic" >
  10. <span class="count" :style="{color: item.color}" >
  11. <CountUp style="height: 64px" :end-val="item.value" :duration="duration(item.value)" />
  12. </span>
  13. <span>{{item.unit}}</span>
  14. </div>
  15. <div class="label" >
  16. {{item.label}}
  17. </div>
  18. </a-col>
  19. <!-- <vueCountTo :startVal='2' :endVal='2023' :duration='3000' /> -->
  20. </a-row>
  21. </a-card>
  22. </template>
  23. <script lang='ts' setup >
  24. import CountUp from 'vue-countup-v3'
  25. interface IProps {
  26. title: string,
  27. list: {value: string | number, key?: string, label: string, color: string, unit: string }[]
  28. }
  29. const duration = (duration: number | string) => {
  30. const count = Number(duration)
  31. if (count < 10) return 0
  32. else if (count < 100) return 2
  33. else if (count < 1000) return 3
  34. else if (count > 1000) return 5
  35. }
  36. const props = defineProps<IProps>()
  37. </script>
  38. <style lang='less' scoped >
  39. @import '~@/styles/theme.less';
  40. .statistic {
  41. color: @sublabel-color;
  42. height: 70px;
  43. .count {
  44. font-size: 48px;
  45. margin-right: 10px;
  46. }
  47. }
  48. .label {
  49. font-size: 18px;
  50. color: @sublabel-color;
  51. }
  52. </style>