show-marks.vue 724 B

12345678910111213141516171819202122232425262728293031323334353637383940
  1. <template>
  2. <div class="slider-demo-block">
  3. <el-slider v-model="value" range :marks="marks" />
  4. </div>
  5. </template>
  6. <script lang="ts" setup>
  7. import { reactive, ref } from 'vue'
  8. import type { CSSProperties } from 'vue'
  9. interface Mark {
  10. style: CSSProperties
  11. label: string
  12. }
  13. type Marks = Record<number, Mark | string>
  14. const value = ref([30, 60])
  15. const marks = reactive<Marks>({
  16. 0: '0°C',
  17. 8: '8°C',
  18. 37: '37°C',
  19. 50: {
  20. style: {
  21. color: '#1989FA',
  22. },
  23. label: '50%',
  24. },
  25. })
  26. </script>
  27. <style scoped>
  28. .slider-demo-block {
  29. display: flex;
  30. align-items: center;
  31. }
  32. .slider-demo-block .el-slider {
  33. margin-top: 0;
  34. margin-left: 12px;
  35. }
  36. </style>