rolling-number.uvue 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. <template>
  2. <cl-page>
  3. <view class="p-3">
  4. <demo-item :label="t('基础用法')">
  5. <cl-rolling-number :value="value"></cl-rolling-number>
  6. <view class="flex flex-row mt-2">
  7. <cl-button icon="add-line" size="small" @tap="add"></cl-button>
  8. <cl-button
  9. icon="subtract-line"
  10. type="light"
  11. size="small"
  12. @tap="sub"
  13. ></cl-button>
  14. </view>
  15. </demo-item>
  16. <demo-item :label="t('自定义')">
  17. <view class="flex flex-col items-center">
  18. <cl-rolling-number
  19. :value="value"
  20. :pt="{
  21. className: parseClass([[isCustom, '!text-3xl']]),
  22. color: isCustom ? 'primary' : ''
  23. }"
  24. :duration="isSpeed ? 300 : 1000"
  25. :decimals="isDecimals ? 2 : 0"
  26. ></cl-rolling-number>
  27. <view class="flex flex-row mt-2">
  28. <cl-button icon="add-line" size="small" @tap="add"></cl-button>
  29. <cl-button
  30. icon="subtract-line"
  31. type="light"
  32. size="small"
  33. @tap="sub"
  34. ></cl-button>
  35. </view>
  36. </view>
  37. <cl-list border class="mt-3">
  38. <cl-list-item :label="t('加快滚动速度')">
  39. <cl-switch v-model="isSpeed"></cl-switch>
  40. </cl-list-item>
  41. <cl-list-item :label="t('显示小数位数')">
  42. <cl-switch v-model="isDecimals"></cl-switch>
  43. </cl-list-item>
  44. <cl-list-item :label="t('自定义样式')">
  45. <cl-switch v-model="isCustom"></cl-switch>
  46. </cl-list-item>
  47. </cl-list>
  48. </demo-item>
  49. </view>
  50. </cl-page>
  51. </template>
  52. <script lang="ts" setup>
  53. import { t } from "@/locale";
  54. import DemoItem from "../components/item.uvue";
  55. import { ref } from "vue";
  56. import { parseClass } from "@/cool";
  57. const value = ref(100);
  58. const isSpeed = ref(false);
  59. const isDecimals = ref(false);
  60. const isCustom = ref(false);
  61. function add() {
  62. value.value += 100;
  63. }
  64. function sub() {
  65. value.value -= 100;
  66. }
  67. </script>