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.

43 lines
1.1 KiB

2 months ago
  1. import { sleep } from '../../libs/function/index';
  2. export default {
  3. data() {
  4. return {
  5. sliderRect: {},
  6. info: {
  7. width: null,
  8. left: null,
  9. step: this.step,
  10. disabled: this.disabled,
  11. min: this.min,
  12. max: this.max,
  13. value: this.value
  14. }
  15. }
  16. },
  17. mounted() {
  18. this.init()
  19. },
  20. methods: {
  21. init() {
  22. this.getSliderRect()
  23. },
  24. // 获取slider尺寸
  25. getSliderRect() {
  26. // 获取滑块条的尺寸信息
  27. sleep().then(() => {
  28. this.$uGetRect('.u-slider').then((rect) => {
  29. this.info.width = rect.width
  30. this.info.left = rect.left
  31. })
  32. })
  33. },
  34. // 此方法由wxs调用,用于修改v-model绑定的值
  35. updateValue(value) {
  36. this.$emit('input', value)
  37. },
  38. // 此方法由wxs调用,发出事件
  39. emitEvent(e) {
  40. this.$emit(e.event, e.value ? e.value : this.value)
  41. }
  42. }
  43. }