input-number.uvue 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  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 ? 30 : 24"
  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, t } from "@/.cool";
  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. function onChange(value: number) {
  77. console.log(value);
  78. }
  79. </script>