rate.uvue 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. <template>
  2. <cl-page>
  3. <view class="p-3">
  4. <demo-item :label="t('基础用法')">
  5. <cl-rate v-model="num"></cl-rate>
  6. </demo-item>
  7. <demo-item :label="t('自定义')">
  8. <cl-rate
  9. v-model="num2"
  10. :disabled="isDisabled"
  11. :show-score="isShowScore"
  12. :allow-half="isAllowHalf"
  13. :size="isSize ? 50 : 40"
  14. :void-icon="isIcon ? 'heart-fill' : 'star-fill'"
  15. :icon="isIcon ? 'heart-fill' : 'star-fill'"
  16. ></cl-rate>
  17. <cl-list
  18. border
  19. :pt="{
  20. className: 'mt-3'
  21. }"
  22. >
  23. <cl-list-item :label="t('只读')">
  24. <cl-switch v-model="isDisabled"></cl-switch>
  25. </cl-list-item>
  26. <cl-list-item :label="t('显示分数')">
  27. <cl-switch v-model="isShowScore"></cl-switch>
  28. </cl-list-item>
  29. <cl-list-item :label="t('允许半星')">
  30. <cl-switch v-model="isAllowHalf"></cl-switch>
  31. </cl-list-item>
  32. <cl-list-item :label="t('换个图标')">
  33. <cl-switch v-model="isIcon"></cl-switch>
  34. </cl-list-item>
  35. <cl-list-item :label="t('大一点')">
  36. <cl-switch v-model="isSize"></cl-switch>
  37. </cl-list-item>
  38. </cl-list>
  39. </demo-item>
  40. </view>
  41. </cl-page>
  42. </template>
  43. <script lang="ts" setup>
  44. import { ref } from "vue";
  45. import DemoItem from "../components/item.uvue";
  46. import { t } from "@/locale";
  47. const num = ref(1);
  48. const num2 = ref(3.5);
  49. const isDisabled = ref(false);
  50. const isShowScore = ref(true);
  51. const isAllowHalf = ref(true);
  52. const isSize = ref(false);
  53. const isIcon = ref(false);
  54. </script>