index.vue 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. <template>
  2. <view class="demo-slider-range">
  3. <view class="section-title">普通用法</view>
  4. <view class="slider-item">
  5. <slider-range
  6. :value="slider1.rangeValue"
  7. :min="slider1.min"
  8. :max="slider1.max"
  9. :step="slider1.step"
  10. :bar-height="barHeight"
  11. :block-size="blockSize"
  12. :background-color="backgroundColor"
  13. :format="format1"
  14. @change="handleRangeChange"
  15. ></slider-range>
  16. </view>
  17. <view class="section-title">自定义</view>
  18. <view class="slider-item">
  19. <slider-range
  20. :value="slider2.rangeValue"
  21. :min="slider2.min"
  22. :max="slider2.max"
  23. :step="slider2.step"
  24. :bar-height="barHeight"
  25. :block-size="blockSize"
  26. :background-color="backgroundColor"
  27. :active-color="slider2.activeColor"
  28. :format="format2"
  29. :decorationVisible="slider2.decorationVisible"
  30. @change="handleRangeChange"
  31. ></slider-range>
  32. </view>
  33. </view>
  34. </template>
  35. <script>
  36. import SliderRange from '../../components/slider-range/index.vue'
  37. export default {
  38. components: {
  39. SliderRange,
  40. },
  41. data() {
  42. return {
  43. barHeight: 3,
  44. blockSize: 26,
  45. backgroundColor: '#EEEEF6',
  46. slider1: {
  47. min: 50,
  48. max: 200,
  49. step: 10,
  50. rangeValue: [50, 150],
  51. },
  52. slider2: {
  53. rangeMin: 0,
  54. rangMax: 100,
  55. rangeValue: [8, 80],
  56. step: 1,
  57. activeColor: '#FF6B00',
  58. decorationVisible: true,
  59. },
  60. }
  61. },
  62. methods: {
  63. format1(val) {
  64. return val
  65. },
  66. format2(val) {
  67. return `${val}%`
  68. },
  69. handleRangeChange(e) {
  70. this.rangeValue = e
  71. },
  72. },
  73. }
  74. </script>
  75. <style>
  76. .demo-slider-range {
  77. background-color: #fff;
  78. padding: 100rpx 40rpx 0;
  79. }
  80. .section-title {
  81. padding: 0 0 20rpx;
  82. color: #666;
  83. }
  84. .slider-item:not(:last-child) {
  85. margin-bottom: 100rpx;
  86. }
  87. </style>