slider.uvue 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. <template>
  2. <cl-page>
  3. <view class="p-3">
  4. <demo-item :label="t('基础用法')">
  5. <cl-slider v-model="num"></cl-slider>
  6. </demo-item>
  7. <demo-item :label="t('范围选择')">
  8. <cl-text
  9. :pt="{
  10. className: 'mb-3'
  11. }"
  12. >{{ num2[0] }} ~ {{ num2[1] }}</cl-text
  13. >
  14. <cl-slider v-model:values="num2" range></cl-slider>
  15. </demo-item>
  16. <demo-item :label="t('自定义')">
  17. <cl-slider
  18. v-model="num3"
  19. :disabled="isDisabled"
  20. :show-value="isShowValue"
  21. :block-size="isSize ? 50 : 40"
  22. :track-height="isSize ? 12 : 8"
  23. :step="isStep ? 10 : 1"
  24. :max="isMax ? 50 : 100"
  25. :pt="{
  26. thumb: {
  27. className: isColor ? '!bg-red-500' : ''
  28. },
  29. progress: {
  30. className: isColor ? '!bg-red-200' : ''
  31. }
  32. }"
  33. ></cl-slider>
  34. <cl-list
  35. border
  36. :pt="{
  37. className: 'mt-3'
  38. }"
  39. >
  40. <cl-list-item :label="t('显示值')">
  41. <cl-switch v-model="isShowValue"></cl-switch>
  42. </cl-list-item>
  43. <cl-list-item :label="t('步长10')">
  44. <cl-switch v-model="isStep"></cl-switch>
  45. </cl-list-item>
  46. <cl-list-item :label="t('滑块大点')">
  47. <cl-switch v-model="isSize"></cl-switch>
  48. </cl-list-item>
  49. <cl-list-item :label="t('换个颜色')">
  50. <cl-switch v-model="isColor"></cl-switch>
  51. </cl-list-item>
  52. <cl-list-item :label="t('最大50')">
  53. <cl-switch v-model="isMax"></cl-switch>
  54. </cl-list-item>
  55. <cl-list-item :label="t('禁用')">
  56. <cl-switch v-model="isDisabled"></cl-switch>
  57. </cl-list-item>
  58. </cl-list>
  59. </demo-item>
  60. </view>
  61. </cl-page>
  62. </template>
  63. <script lang="ts" setup>
  64. import { ref } from "vue";
  65. import DemoItem from "../components/item.uvue";
  66. import { t } from "@/locale";
  67. const num = ref(60);
  68. const num2 = ref<number[]>([10, 20]);
  69. const num3 = ref(35);
  70. const isDisabled = ref(false);
  71. const isShowValue = ref(true);
  72. const isStep = ref(false);
  73. const isSize = ref(false);
  74. const isMax = ref(false);
  75. const isColor = ref(false);
  76. </script>