u-slider.vue 1.0 KB

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