综合办公系统
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

uv-slider.vue 1.3KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. <template>
  2. <view
  3. class="uv-slider"
  4. :style="[$uv.addStyle(customStyle)]"
  5. >
  6. <slider
  7. :min="min"
  8. :max="max"
  9. :step="step"
  10. :value="sliderValue"
  11. :activeColor="activeColor"
  12. :backgroundColor="backgroundColor"
  13. :blockSize="$uv.getPx(blockSize)"
  14. :blockColor="blockColor"
  15. :showValue="showValue"
  16. :disabled="disabled"
  17. @changing="changingHandler"
  18. @change="changeHandler"
  19. ></slider>
  20. </view>
  21. </template>
  22. <script>
  23. import mpMixin from '@/uni_modules/uv-ui-tools/libs/mixin/mpMixin.js'
  24. import mixin from '@/uni_modules/uv-ui-tools/libs/mixin/mixin.js'
  25. import props from './props.js'
  26. export default {
  27. name: 'uv-slider',
  28. mixins: [mpMixin, mixin, props],
  29. computed: {
  30. sliderValue(){
  31. return this.value || this.modelValue;
  32. }
  33. },
  34. methods: {
  35. // 拖动过程中触发
  36. changingHandler(e) {
  37. const { value } = e.detail
  38. // 更新v-model的值
  39. this.$emit('input', value)
  40. this.$emit('update:modelValue',value)
  41. // 触发事件
  42. this.$emit('changing', value)
  43. },
  44. // 滑动结束时触发
  45. changeHandler(e) {
  46. const {
  47. value
  48. } = e.detail
  49. // 更新v-model的值
  50. this.$emit('input', value)
  51. this.$emit('update:modelValue',value)
  52. // 触发事件
  53. this.$emit('change', value)
  54. }
  55. }
  56. }
  57. </script>