input-number.uvue 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  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. ></cl-input-number>
  31. </view>
  32. <cl-list border>
  33. <cl-list-item :label="t('步进为10')">
  34. <cl-switch v-model="isStep"></cl-switch>
  35. </cl-list-item>
  36. <cl-list-item :label="t('最小为10')">
  37. <cl-switch v-model="isMin"></cl-switch>
  38. </cl-list-item>
  39. <cl-list-item :label="t('最大为50')">
  40. <cl-switch v-model="isMax"></cl-switch>
  41. </cl-list-item>
  42. <cl-list-item :label="t('可以小数')">
  43. <cl-switch v-model="isDigit"></cl-switch>
  44. </cl-list-item>
  45. <cl-list-item :label="t('可以输入')">
  46. <cl-switch v-model="isInput"></cl-switch>
  47. </cl-list-item>
  48. <cl-list-item :label="t('禁用')">
  49. <cl-switch v-model="isDisabled"></cl-switch>
  50. </cl-list-item>
  51. <cl-list-item :label="t('大一点')">
  52. <cl-switch v-model="isSize"></cl-switch>
  53. </cl-list-item>
  54. <cl-list-item :label="t('自定义样式')">
  55. <cl-switch v-model="isCustom"></cl-switch>
  56. </cl-list-item>
  57. </cl-list>
  58. </demo-item>
  59. </view>
  60. </cl-page>
  61. </template>
  62. <script lang="ts" setup>
  63. import { ref } from "vue";
  64. import DemoItem from "../components/item.uvue";
  65. import { parseClass } from "@/cool";
  66. import { t } from "@/locale";
  67. const num = ref(0);
  68. const isStep = ref(false);
  69. const isMin = ref(false);
  70. const isMax = ref(false);
  71. const isDigit = ref(false);
  72. const isInput = ref(true);
  73. const isDisabled = ref(false);
  74. const isSize = ref(false);
  75. const isCustom = ref(false);
  76. </script>