input-number.uvue 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. <template>
  2. <cl-page>
  3. <view class="p-3">
  4. <demo-item :label="t('基础用法')">
  5. <cl-input-number></cl-input-number>
  6. </demo-item>
  7. <demo-item :label="t('自定义')">
  8. <view class="mb-5 flex flex-row justify-center">
  9. <cl-input-number
  10. v-model="num"
  11. :step="isStep ? 10 : 1"
  12. :min="isMin ? 10 : 0"
  13. :max="isMax ? 50 : 100"
  14. :input-type="isDigit ? 'digit' : 'number'"
  15. :inputable="isInput"
  16. :disabled="isDisabled"
  17. :size="isSize ? 60 : 50"
  18. :pt="{
  19. op: {
  20. className: parseClass({
  21. '!rounded-full': isCustom
  22. })
  23. },
  24. value: {
  25. className: parseClass({
  26. '!rounded-full': isCustom
  27. })
  28. }
  29. }"
  30. @change="onChange"
  31. ></cl-input-number>
  32. </view>
  33. <cl-list border>
  34. <cl-list-item :label="t('步进为10')">
  35. <cl-switch v-model="isStep"></cl-switch>
  36. </cl-list-item>
  37. <cl-list-item :label="t('最小为10')">
  38. <cl-switch v-model="isMin"></cl-switch>
  39. </cl-list-item>
  40. <cl-list-item :label="t('最大为50')">
  41. <cl-switch v-model="isMax"></cl-switch>
  42. </cl-list-item>
  43. <cl-list-item :label="t('可以小数')">
  44. <cl-switch v-model="isDigit"></cl-switch>
  45. </cl-list-item>
  46. <cl-list-item :label="t('可以输入')">
  47. <cl-switch v-model="isInput"></cl-switch>
  48. </cl-list-item>
  49. <cl-list-item :label="t('禁用')">
  50. <cl-switch v-model="isDisabled"></cl-switch>
  51. </cl-list-item>
  52. <cl-list-item :label="t('大一点')">
  53. <cl-switch v-model="isSize"></cl-switch>
  54. </cl-list-item>
  55. <cl-list-item :label="t('自定义样式')">
  56. <cl-switch v-model="isCustom"></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 { parseClass } from "@/cool";
  67. import { t } from "@/locale";
  68. const num = ref(0);
  69. const isStep = ref(false);
  70. const isMin = ref(false);
  71. const isMax = ref(false);
  72. const isDigit = ref(false);
  73. const isInput = ref(true);
  74. const isDisabled = ref(false);
  75. const isSize = ref(false);
  76. const isCustom = ref(false);
  77. function onChange(value: number) {
  78. console.log(value);
  79. }
  80. </script>