uni-events-helper-wx
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.

54 lines
1.1 KiB

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