hy-app 0.4.13 → 0.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/components/hy-action-sheet/hy-action-sheet.vue +155 -238
- package/components/hy-action-sheet/props.ts +68 -15
- package/components/hy-action-sheet/typing.d.ts +115 -115
- package/components/hy-address-picker/hy-address-picker.vue +185 -289
- package/components/hy-address-picker/props.ts +97 -21
- package/components/hy-address-picker/typing.d.ts +90 -89
- package/components/hy-avatar/hy-avatar.vue +121 -204
- package/components/hy-avatar/props.ts +76 -18
- package/components/hy-avatar/typing.d.ts +63 -62
- package/components/hy-back-top/hy-back-top.vue +65 -120
- package/components/hy-back-top/props.ts +57 -16
- package/components/hy-back-top/typing.d.ts +43 -42
- package/components/hy-badge/hy-badge.vue +66 -138
- package/components/hy-badge/props.ts +73 -17
- package/components/hy-badge/typing.d.ts +59 -58
- package/components/hy-button/hy-button.vue +226 -375
- package/components/hy-button/props.ts +129 -158
- package/components/hy-calendar/header.vue +48 -64
- package/components/hy-calendar/hy-calendar.vue +274 -438
- package/components/hy-calendar/month.vue +508 -516
- package/components/hy-calendar/props.ts +157 -35
- package/components/hy-calendar/typing.d.ts +129 -128
- package/components/hy-card/hy-card.vue +118 -240
- package/components/hy-card/index.scss +1 -2
- package/components/hy-card/props.ts +122 -27
- package/components/hy-card/typing.d.ts +119 -118
- package/components/hy-cell/hy-cell.vue +176 -258
- package/components/hy-cell/props.ts +71 -17
- package/components/hy-cell/typing.d.ts +87 -86
- package/components/hy-check-button/hy-check-button.vue +69 -139
- package/components/hy-check-button/props.ts +72 -18
- package/components/hy-check-button/typing.d.ts +74 -73
- package/components/hy-checkbox/hy-checkbox.vue +170 -263
- package/components/hy-checkbox/props.ts +94 -24
- package/components/hy-checkbox/typing.d.ts +72 -72
- package/components/hy-checkbox-group/hy-checkbox-group.vue +25 -100
- package/components/hy-checkbox-group/props.ts +80 -0
- package/components/hy-checkbox-group/typing.d.ts +65 -65
- package/components/hy-checkbox-item/hy-checkbox-item.vue +140 -177
- package/components/hy-checkbox-item/props.ts +24 -0
- package/components/hy-checkbox-item/typing.d.ts +4 -3
- package/components/hy-code-input/hy-code-input.vue +179 -262
- package/components/hy-code-input/props.ts +84 -18
- package/components/hy-code-input/typing.d.ts +71 -71
- package/components/hy-config-provider/hy-config-provider.vue +28 -50
- package/components/hy-config-provider/props.ts +26 -11
- package/components/hy-config-provider/typing.d.ts +20 -20
- package/components/hy-count-down/hy-count-down.vue +103 -131
- package/components/hy-count-down/props.ts +30 -8
- package/components/hy-count-down/typing.d.ts +25 -25
- package/components/hy-count-to/hy-count-to.vue +148 -213
- package/components/hy-count-to/props.ts +60 -15
- package/components/hy-count-to/typing.d.ts +46 -46
- package/components/hy-coupon/README.md +133 -0
- package/components/hy-coupon/hy-coupon.vue +180 -0
- package/components/hy-coupon/index.scss +553 -0
- package/components/hy-coupon/props.ts +129 -0
- package/components/hy-coupon/typing.d.ts +146 -0
- package/components/hy-datetime-picker/hy-datetime-picker.vue +415 -580
- package/components/hy-datetime-picker/props.ts +142 -32
- package/components/hy-datetime-picker/typing.d.ts +132 -132
- package/components/hy-divider/hy-divider.vue +90 -169
- package/components/hy-divider/props.ts +78 -19
- package/components/hy-divider/typing.d.ts +60 -60
- package/components/hy-dropdown/hy-dropdown.vue +37 -71
- package/components/hy-dropdown/props.ts +38 -15
- package/components/hy-dropdown/typing.d.ts +44 -44
- package/components/hy-dropdown-item/hy-dropdown-item.vue +141 -173
- package/components/hy-dropdown-item/props.ts +19 -8
- package/components/hy-empty/hy-empty.vue +75 -129
- package/components/hy-empty/props.ts +57 -15
- package/components/hy-empty/typing.d.ts +84 -84
- package/components/hy-flex/hy-flex.vue +33 -88
- package/components/hy-flex/props.ts +58 -0
- package/components/hy-flex/typing.d.ts +14 -16
- package/components/hy-float-button/hy-float-button.vue +289 -406
- package/components/hy-float-button/props.ts +109 -25
- package/components/hy-folding-panel/hy-folding-panel.vue +86 -374
- package/components/hy-folding-panel/props.ts +40 -15
- package/components/hy-folding-panel/typing.d.ts +52 -63
- package/components/hy-folding-panel-item/hy-folding-panel-item.vue +186 -228
- package/components/hy-folding-panel-item/index.scss +87 -0
- package/components/hy-folding-panel-item/props.ts +81 -0
- package/components/hy-folding-panel-item/typing.d.ts +23 -0
- package/components/hy-form/hy-form.vue +172 -212
- package/components/hy-form/props.ts +37 -0
- package/components/hy-form/typing.d.ts +68 -61
- package/components/hy-form-group/typing.d.ts +74 -74
- package/components/hy-form-item/hy-form-item.vue +100 -129
- package/components/hy-form-item/props.ts +25 -0
- package/components/hy-form-item/typing.d.ts +40 -37
- package/components/hy-grid/hy-grid.vue +76 -132
- package/components/hy-grid/props.ts +58 -16
- package/components/hy-grid/typing.d.ts +66 -66
- package/components/hy-icon/hy-icon.vue +84 -161
- package/components/hy-icon/props.ts +76 -22
- package/components/hy-icon/typing.d.ts +83 -82
- package/components/hy-image/hy-image.vue +142 -272
- package/components/hy-image/props.ts +105 -23
- package/components/hy-image/typing.d.ts +84 -87
- package/components/hy-input/hy-input.vue +230 -421
- package/components/hy-input/props.ts +183 -35
- package/components/hy-input/typing.d.ts +169 -169
- package/components/hy-line/hy-line.vue +34 -72
- package/components/hy-line/props.ts +41 -10
- package/components/hy-line/typing.d.ts +29 -29
- package/components/hy-line-progress/hy-line-progress.vue +66 -101
- package/components/hy-line-progress/props.ts +31 -10
- package/components/hy-line-progress/typing.d.ts +29 -29
- package/components/hy-list/hy-list.vue +151 -220
- package/components/hy-list/props.ts +67 -16
- package/components/hy-list/typing.d.ts +52 -52
- package/components/hy-loading/hy-loading.vue +63 -119
- package/components/hy-loading/props.ts +63 -15
- package/components/hy-loading/typing.d.ts +49 -49
- package/components/hy-menu/hy-menu.vue +124 -166
- package/components/hy-menu/props.ts +42 -10
- package/components/hy-menu/typing.d.ts +60 -60
- package/components/hy-modal/hy-modal.vue +127 -218
- package/components/hy-modal/props.ts +89 -24
- package/components/hy-navbar/hy-navbar.vue +104 -177
- package/components/hy-navbar/props.ts +76 -22
- package/components/hy-navbar/typing.d.ts +81 -81
- package/components/hy-notice-bar/hy-notice-bar.vue +67 -144
- package/components/hy-notice-bar/props.ts +80 -19
- package/components/hy-notice-bar/typing.d.ts +62 -62
- package/components/hy-notify/hy-notify.vue +128 -177
- package/components/hy-notify/props.ts +49 -12
- package/components/hy-notify/typing.d.ts +45 -41
- package/components/hy-number-step/hy-number-step.vue +281 -394
- package/components/hy-number-step/props.ts +110 -27
- package/components/hy-number-step/typing.d.ts +120 -120
- package/components/hy-overlay/hy-overlay.vue +39 -66
- package/components/hy-overlay/props.ts +31 -8
- package/components/hy-pagination/hy-pagination.vue +100 -155
- package/components/hy-pagination/props.ts +53 -13
- package/components/hy-picker/hy-picker.vue +309 -430
- package/components/hy-picker/index.scss +8 -12
- package/components/hy-picker/props.ts +110 -26
- package/components/hy-popover/hy-popover.vue +190 -252
- package/components/hy-popover/props.ts +48 -10
- package/components/hy-popup/hy-popup.vue +162 -248
- package/components/hy-popup/props.ts +82 -18
- package/components/hy-price/hy-price.vue +45 -104
- package/components/hy-price/props.ts +52 -12
- package/components/hy-price/typing.d.ts +41 -36
- package/components/hy-qrcode/hy-qrcode.vue +115 -185
- package/components/hy-qrcode/props.ts +68 -18
- package/components/hy-qrcode/typing.d.ts +67 -66
- package/components/hy-radio/hy-radio.vue +161 -259
- package/components/hy-radio/props.ts +95 -25
- package/components/hy-radio/typing.d.ts +85 -84
- package/components/hy-rate/hy-rate.vue +185 -270
- package/components/hy-rate/props.ts +76 -18
- package/components/hy-rate/typing.d.ts +61 -60
- package/components/hy-read-more/hy-read-more.vue +93 -136
- package/components/hy-read-more/props.ts +43 -13
- package/components/hy-scroll-list/hy-scroll-list.vue +81 -102
- package/components/hy-scroll-list/props.ts +22 -11
- package/components/hy-search/hy-search.vue +155 -284
- package/components/hy-search/props.ts +130 -25
- package/components/hy-signature/hy-signature.vue +491 -635
- package/components/hy-signature/props.ts +115 -26
- package/components/hy-signature/typing.d.ts +138 -138
- package/components/hy-slider/hy-slider.vue +388 -477
- package/components/hy-slider/props.ts +75 -19
- package/components/hy-steps/hy-steps.vue +212 -279
- package/components/hy-steps/props.ts +47 -13
- package/components/hy-submit-bar/hy-submit-bar.vue +137 -222
- package/components/hy-submit-bar/props.ts +89 -20
- package/components/hy-submit-bar/typing.d.ts +86 -85
- package/components/hy-subsection/hy-subsection.vue +132 -185
- package/components/hy-subsection/props.ts +50 -17
- package/components/hy-subsection/typing.d.ts +52 -52
- package/components/hy-swipe-action/hy-swipe-action.vue +228 -283
- package/components/hy-swipe-action/props.ts +43 -18
- package/components/hy-swipe-action/typing.d.ts +46 -46
- package/components/hy-swiper/hy-swiper.vue +159 -286
- package/components/hy-swiper/props.ts +126 -28
- package/components/hy-swiper/typing.d.ts +115 -115
- package/components/hy-switch/hy-switch.vue +112 -176
- package/components/hy-switch/props.ts +60 -15
- package/components/hy-switch/typing.d.ts +63 -63
- package/components/hy-tabBar/hy-tabBar.vue +64 -60
- package/components/hy-tabs/hy-tabs.vue +277 -380
- package/components/hy-tabs/props.ts +75 -18
- package/components/hy-tag/hy-tag.vue +111 -204
- package/components/hy-tag/props.ts +81 -19
- package/components/hy-text/hy-text.vue +200 -322
- package/components/hy-text/props.ts +107 -28
- package/components/hy-textarea/hy-textarea.vue +147 -256
- package/components/hy-textarea/props.ts +112 -25
- package/components/hy-textarea/typing.d.ts +42 -42
- package/components/hy-toast/hy-toast.vue +135 -143
- package/components/hy-tooltip/hy-tooltip.vue +220 -306
- package/components/hy-tooltip/props.ts +79 -15
- package/components/hy-transition/hy-transition.vue +111 -138
- package/components/hy-transition/props.ts +30 -8
- package/components/hy-upload/hy-upload.vue +320 -469
- package/components/hy-upload/props.ts +130 -27
- package/components/hy-warn/hy-warn.vue +80 -129
- package/components/hy-warn/props.ts +47 -12
- package/components/hy-waterfall/hy-waterfall.vue +139 -163
- package/components/hy-waterfall/props.ts +19 -7
- package/components/hy-watermark/hy-watermark.vue +762 -870
- package/components/hy-watermark/props.ts +103 -22
- package/global.d.ts +2 -0
- package/libs/css/theme.scss +3 -3
- package/package.json +2 -2
- package/web-types.json +1 -1
- package/components/hy-folding-panel/index.scss +0 -9
|
@@ -1,533 +1,444 @@
|
|
|
1
1
|
<template>
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
<view
|
|
5
|
-
ref="hy-slider__inner"
|
|
6
|
-
class="hy-slider__inner"
|
|
7
|
-
@tap="onClick"
|
|
8
|
-
@onTouchStart="onTouchStart2($event, 1)"
|
|
9
|
-
@touchmove="onTouchMove2($event, 1)"
|
|
10
|
-
@touchend="onTouchEnd2($event, 1)"
|
|
11
|
-
@touchcancel="onTouchEnd2($event, 1)"
|
|
12
|
-
:class="[disabled ? 'hy-slider__disabled' : '']"
|
|
13
|
-
:style="{
|
|
14
|
-
height:
|
|
15
|
-
isRange && showValue
|
|
16
|
-
? addUnit(getPx(blockSize) + 24)
|
|
17
|
-
: addUnit(blockSize),
|
|
18
|
-
}"
|
|
19
|
-
>
|
|
20
|
-
<view
|
|
21
|
-
ref="hy-slider__base"
|
|
22
|
-
class="hy-slider__base"
|
|
23
|
-
:style="[
|
|
24
|
-
{
|
|
25
|
-
height: addUnit(height),
|
|
26
|
-
backgroundColor: inactiveColor,
|
|
27
|
-
},
|
|
28
|
-
]"
|
|
29
|
-
></view>
|
|
30
|
-
<view
|
|
31
|
-
@tap="onClick"
|
|
32
|
-
class="hy-slider__gap"
|
|
33
|
-
:style="[
|
|
34
|
-
barStyle,
|
|
35
|
-
{
|
|
36
|
-
height: addUnit(height),
|
|
37
|
-
marginTop: '-' + addUnit(height),
|
|
38
|
-
backgroundColor: activeColor,
|
|
39
|
-
},
|
|
40
|
-
]"
|
|
41
|
-
></view>
|
|
42
|
-
<view
|
|
43
|
-
v-if="isRange"
|
|
44
|
-
class="hy-slider__gap hy-slider__gap-0"
|
|
45
|
-
:style="[
|
|
46
|
-
barStyle0,
|
|
47
|
-
{
|
|
48
|
-
height: addUnit(height),
|
|
49
|
-
marginTop: '-' + addUnit(height),
|
|
50
|
-
backgroundColor: inactiveColor,
|
|
51
|
-
},
|
|
52
|
-
]"
|
|
53
|
-
></view>
|
|
54
|
-
<text
|
|
55
|
-
v-if="isRange && showValue"
|
|
56
|
-
class="hy-slider__show-range-value"
|
|
57
|
-
:style="{
|
|
58
|
-
left: blockLeft(barStyle0?.width, blockSize),
|
|
59
|
-
}"
|
|
60
|
-
>
|
|
61
|
-
{{ rangeValue[0] }}
|
|
62
|
-
</text>
|
|
63
|
-
<text
|
|
64
|
-
v-if="isRange && showValue"
|
|
65
|
-
class="hy-slider__show-range-value"
|
|
66
|
-
:style="{
|
|
67
|
-
left: blockLeft(barStyle?.width, blockSize),
|
|
68
|
-
}"
|
|
69
|
-
>
|
|
70
|
-
{{ rangeValue[1] }}
|
|
71
|
-
</text>
|
|
72
|
-
<template v-if="isRange">
|
|
73
|
-
<view
|
|
74
|
-
class="hy-slider__button--wrap hy-slider__button--wrap-0"
|
|
75
|
-
@touchstart="onTouchStart($event, 0)"
|
|
76
|
-
@touchmove="onTouchMove($event, 0)"
|
|
77
|
-
@touchend="onTouchEnd($event, 0)"
|
|
78
|
-
@touchcancel="onTouchEnd($event, 0)"
|
|
79
|
-
:style="{
|
|
80
|
-
left: blockLeft(barStyle0?.width, blockSize),
|
|
81
|
-
}"
|
|
82
|
-
>
|
|
83
|
-
<slot name="min" v-if="$slots.min || $slots.$min" />
|
|
2
|
+
<view :class="['hy-slider', customClass]" :style="[customStyle]">
|
|
3
|
+
<template v-if="!useNative || isRange">
|
|
84
4
|
<view
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
5
|
+
ref="hy-slider__inner"
|
|
6
|
+
class="hy-slider__inner"
|
|
7
|
+
@tap="onClick"
|
|
8
|
+
@onTouchStart="onTouchStart2($event, 1)"
|
|
9
|
+
@touchmove="onTouchMove2($event, 1)"
|
|
10
|
+
@touchend="onTouchEnd2($event, 1)"
|
|
11
|
+
@touchcancel="onTouchEnd2($event, 1)"
|
|
12
|
+
:class="[disabled ? 'hy-slider__disabled' : '']"
|
|
13
|
+
:style="{
|
|
14
|
+
height:
|
|
15
|
+
isRange && showValue ? addUnit(getPx(blockSize) + 24) : addUnit(blockSize)
|
|
16
|
+
}"
|
|
17
|
+
>
|
|
18
|
+
<view
|
|
19
|
+
ref="hy-slider__base"
|
|
20
|
+
class="hy-slider__base"
|
|
21
|
+
:style="[
|
|
22
|
+
{
|
|
23
|
+
height: addUnit(height),
|
|
24
|
+
backgroundColor: inactiveColor
|
|
25
|
+
}
|
|
26
|
+
]"
|
|
27
|
+
></view>
|
|
28
|
+
<view
|
|
29
|
+
@tap="onClick"
|
|
30
|
+
class="hy-slider__gap"
|
|
31
|
+
:style="[
|
|
32
|
+
barStyle,
|
|
33
|
+
{
|
|
34
|
+
height: addUnit(height),
|
|
35
|
+
marginTop: '-' + addUnit(height),
|
|
36
|
+
backgroundColor: activeColor
|
|
37
|
+
}
|
|
38
|
+
]"
|
|
39
|
+
></view>
|
|
40
|
+
<view
|
|
41
|
+
v-if="isRange"
|
|
42
|
+
class="hy-slider__gap hy-slider__gap-0"
|
|
43
|
+
:style="[
|
|
44
|
+
barStyle0,
|
|
45
|
+
{
|
|
46
|
+
height: addUnit(height),
|
|
47
|
+
marginTop: '-' + addUnit(height),
|
|
48
|
+
backgroundColor: inactiveColor
|
|
49
|
+
}
|
|
50
|
+
]"
|
|
51
|
+
></view>
|
|
52
|
+
<text
|
|
53
|
+
v-if="isRange && showValue"
|
|
54
|
+
class="hy-slider__show-range-value"
|
|
55
|
+
:style="{
|
|
56
|
+
left: blockLeft(barStyle0?.width, blockSize)
|
|
57
|
+
}"
|
|
58
|
+
>
|
|
59
|
+
{{ rangeValue[0] }}
|
|
60
|
+
</text>
|
|
61
|
+
<text
|
|
62
|
+
v-if="isRange && showValue"
|
|
63
|
+
class="hy-slider__show-range-value"
|
|
64
|
+
:style="{
|
|
65
|
+
left: blockLeft(barStyle?.width, blockSize)
|
|
66
|
+
}"
|
|
67
|
+
>
|
|
68
|
+
{{ rangeValue[1] }}
|
|
69
|
+
</text>
|
|
70
|
+
<template v-if="isRange">
|
|
71
|
+
<view
|
|
72
|
+
class="hy-slider__button--wrap hy-slider__button--wrap-0"
|
|
73
|
+
@touchstart="onTouchStart($event, 0)"
|
|
74
|
+
@touchmove="onTouchMove($event, 0)"
|
|
75
|
+
@touchend="onTouchEnd($event, 0)"
|
|
76
|
+
@touchcancel="onTouchEnd($event, 0)"
|
|
77
|
+
:style="{
|
|
78
|
+
left: blockLeft(barStyle0?.width, blockSize)
|
|
79
|
+
}"
|
|
80
|
+
>
|
|
81
|
+
<slot name="min" v-if="$slots.min || $slots.$min" />
|
|
82
|
+
<view
|
|
83
|
+
v-else
|
|
84
|
+
class="hy-slider__button"
|
|
85
|
+
:style="[
|
|
86
|
+
blockStyle,
|
|
87
|
+
{
|
|
88
|
+
height: addUnit(blockSize),
|
|
89
|
+
width: addUnit(blockSize),
|
|
90
|
+
backgroundColor: blockColor
|
|
91
|
+
}
|
|
92
|
+
]"
|
|
93
|
+
></view>
|
|
94
|
+
</view>
|
|
95
|
+
</template>
|
|
96
|
+
<view
|
|
97
|
+
class="hy-slider__button--wrap"
|
|
98
|
+
@touchstart="onTouchStart"
|
|
99
|
+
@touchmove="onTouchMove"
|
|
100
|
+
@touchend="onTouchEnd"
|
|
101
|
+
@touchcancel="onTouchEnd"
|
|
102
|
+
:style="{
|
|
103
|
+
left: blockLeft(barStyle?.width, blockSize)
|
|
104
|
+
}"
|
|
105
|
+
>
|
|
106
|
+
<slot name="max" v-if="isRange && ($slots.max || $slots.$max)" />
|
|
107
|
+
<slot v-else-if="$slots.default || $slots.$default" />
|
|
108
|
+
<view
|
|
109
|
+
v-else
|
|
110
|
+
class="hy-slider__button"
|
|
111
|
+
:style="[
|
|
112
|
+
blockStyle,
|
|
113
|
+
{
|
|
114
|
+
height: addUnit(blockSize),
|
|
115
|
+
width: addUnit(blockSize),
|
|
116
|
+
backgroundColor: blockColor
|
|
117
|
+
}
|
|
118
|
+
]"
|
|
119
|
+
></view>
|
|
120
|
+
</view>
|
|
121
|
+
</view>
|
|
122
|
+
<view class="hy-slider__show-value" v-if="showValue && !isRange">{{ modelValue }}</view>
|
|
97
123
|
</template>
|
|
98
|
-
<
|
|
99
|
-
|
|
100
|
-
@touchstart="onTouchStart"
|
|
101
|
-
@touchmove="onTouchMove"
|
|
102
|
-
@touchend="onTouchEnd"
|
|
103
|
-
@touchcancel="onTouchEnd"
|
|
104
|
-
:style="{
|
|
105
|
-
left: blockLeft(barStyle?.width, blockSize),
|
|
106
|
-
}"
|
|
107
|
-
>
|
|
108
|
-
<slot name="max" v-if="isRange && ($slots.max || $slots.$max)" />
|
|
109
|
-
<slot v-else-if="$slots.default || $slots.$default" />
|
|
110
|
-
<view
|
|
124
|
+
<slider
|
|
125
|
+
class="hy-slider__native"
|
|
111
126
|
v-else
|
|
112
|
-
|
|
113
|
-
:
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
}}</view>
|
|
127
|
-
</template>
|
|
128
|
-
<slider
|
|
129
|
-
class="hy-slider__native"
|
|
130
|
-
v-else
|
|
131
|
-
:min="min"
|
|
132
|
-
:max="max"
|
|
133
|
-
:step="step"
|
|
134
|
-
:value="modelValue"
|
|
135
|
-
:activeColor="activeColor"
|
|
136
|
-
:backgroundColor="inactiveColor"
|
|
137
|
-
:blockSize="blockSize"
|
|
138
|
-
:blockColor="blockColor"
|
|
139
|
-
:showValue="showValue"
|
|
140
|
-
:disabled="disabled"
|
|
141
|
-
@changing="changingHandler"
|
|
142
|
-
@change="changeHandler"
|
|
143
|
-
></slider>
|
|
144
|
-
</view>
|
|
127
|
+
:min="min"
|
|
128
|
+
:max="max"
|
|
129
|
+
:step="step"
|
|
130
|
+
:value="modelValue"
|
|
131
|
+
:activeColor="activeColor"
|
|
132
|
+
:backgroundColor="inactiveColor"
|
|
133
|
+
:blockSize="blockSize"
|
|
134
|
+
:blockColor="blockColor"
|
|
135
|
+
:showValue="showValue"
|
|
136
|
+
:disabled="disabled"
|
|
137
|
+
@changing="changingHandler"
|
|
138
|
+
@change="changeHandler"
|
|
139
|
+
></slider>
|
|
140
|
+
</view>
|
|
145
141
|
</template>
|
|
146
142
|
|
|
147
143
|
<script lang="ts">
|
|
148
144
|
export default {
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
}
|
|
145
|
+
name: 'hy-slider',
|
|
146
|
+
options: {
|
|
147
|
+
addGlobalClass: true,
|
|
148
|
+
virtualHost: true,
|
|
149
|
+
styleIsolation: 'shared'
|
|
150
|
+
}
|
|
151
|
+
}
|
|
156
152
|
</script>
|
|
157
153
|
|
|
158
154
|
<script setup lang="ts">
|
|
159
|
-
import { computed, getCurrentInstance, onMounted, ref, watch } from
|
|
160
|
-
import type { CSSProperties
|
|
161
|
-
import { addUnit, error, getRect, getPx } from
|
|
162
|
-
import type { ISliderEmits } from
|
|
163
|
-
import type { SliderOnChangingEvent } from
|
|
155
|
+
import { computed, getCurrentInstance, onMounted, ref, watch } from 'vue'
|
|
156
|
+
import type { CSSProperties } from 'vue'
|
|
157
|
+
import { addUnit, error, getRect, getPx } from '../../libs'
|
|
158
|
+
import type { ISliderEmits } from './typing'
|
|
159
|
+
import type { SliderOnChangingEvent } from '@uni-helper/uni-types'
|
|
160
|
+
import sliderProps from './props'
|
|
164
161
|
|
|
165
162
|
/**
|
|
166
163
|
* 一般用于表单中,手动选择一个区间范围的场景。
|
|
167
164
|
* @displayName hy-slider
|
|
168
165
|
*/
|
|
169
|
-
defineOptions({})
|
|
166
|
+
defineOptions({})
|
|
170
167
|
|
|
171
|
-
|
|
172
|
-
const
|
|
173
|
-
/** 滑块默认值 */
|
|
174
|
-
modelValue: {
|
|
175
|
-
type: Number,
|
|
176
|
-
default: 0,
|
|
177
|
-
},
|
|
178
|
-
/** 滑块的大小,取值范围为 12 - 28 */
|
|
179
|
-
blockSize: {
|
|
180
|
-
type: [String, Number],
|
|
181
|
-
default: 18,
|
|
182
|
-
},
|
|
183
|
-
/** 最小值 */
|
|
184
|
-
min: {
|
|
185
|
-
type: Number,
|
|
186
|
-
default: 0,
|
|
187
|
-
},
|
|
188
|
-
/** 最大值 */
|
|
189
|
-
max: {
|
|
190
|
-
type: Number,
|
|
191
|
-
default: 100,
|
|
192
|
-
},
|
|
193
|
-
/** 步长 */
|
|
194
|
-
step: {
|
|
195
|
-
type: Number,
|
|
196
|
-
default: 1,
|
|
197
|
-
},
|
|
198
|
-
/** 底部选择部分的背景颜色 */
|
|
199
|
-
activeColor: String,
|
|
200
|
-
/** 底部条背景颜色 */
|
|
201
|
-
inactiveColor: String,
|
|
202
|
-
/** 滑块颜色 */
|
|
203
|
-
blockColor: String,
|
|
204
|
-
/** 是否显示当前的选择值 */
|
|
205
|
-
showValue: {
|
|
206
|
-
type: Boolean,
|
|
207
|
-
default: false,
|
|
208
|
-
},
|
|
209
|
-
/** 是否禁用滑块 */
|
|
210
|
-
disabled: {
|
|
211
|
-
type: Boolean,
|
|
212
|
-
default: false,
|
|
213
|
-
},
|
|
214
|
-
/** 是否渲染uni-app框架内置组件 */
|
|
215
|
-
useNative: {
|
|
216
|
-
type: Boolean,
|
|
217
|
-
default: false,
|
|
218
|
-
},
|
|
219
|
-
/** 滑块条高度,单位rpx */
|
|
220
|
-
height: {
|
|
221
|
-
type: [String, Number],
|
|
222
|
-
default: 2,
|
|
223
|
-
},
|
|
224
|
-
/** 双滑块时值 */
|
|
225
|
-
rangeValue: {
|
|
226
|
-
type: Array as unknown as PropType<number[]>,
|
|
227
|
-
default: [0, 0],
|
|
228
|
-
},
|
|
229
|
-
/** 是否区间的模式 */
|
|
230
|
-
isRange: {
|
|
231
|
-
type: Boolean,
|
|
232
|
-
default: false,
|
|
233
|
-
},
|
|
234
|
-
/** 给滑块自定义样式,对象形式 */
|
|
235
|
-
blockStyle: {
|
|
236
|
-
type: Object as PropType<CSSProperties>,
|
|
237
|
-
},
|
|
238
|
-
/** 定义需要用到的外部样式 */
|
|
239
|
-
customStyle: {
|
|
240
|
-
type: Object as PropType<CSSProperties>,
|
|
241
|
-
},
|
|
242
|
-
/** 自定义外部类名 */
|
|
243
|
-
customClass: String,
|
|
244
|
-
});
|
|
245
|
-
const emit = defineEmits<ISliderEmits>();
|
|
168
|
+
const props = defineProps(sliderProps)
|
|
169
|
+
const emit = defineEmits<ISliderEmits>()
|
|
246
170
|
|
|
247
|
-
const startX = ref(0)
|
|
248
|
-
const status = ref(
|
|
249
|
-
const newValue = ref(0)
|
|
250
|
-
const distanceX = ref(0)
|
|
251
|
-
const startValue0 = ref(0)
|
|
252
|
-
const startValue = ref(0)
|
|
253
|
-
const barStyle0 = ref<CSSProperties>()
|
|
254
|
-
const barStyle = ref<CSSProperties>()
|
|
171
|
+
const startX = ref(0)
|
|
172
|
+
const status = ref('end')
|
|
173
|
+
const newValue = ref(0)
|
|
174
|
+
const distanceX = ref(0)
|
|
175
|
+
const startValue0 = ref(0)
|
|
176
|
+
const startValue = ref(0)
|
|
177
|
+
const barStyle0 = ref<CSSProperties>()
|
|
178
|
+
const barStyle = ref<CSSProperties>()
|
|
255
179
|
const sliderRect = ref<UniNamespace.NodeInfo>({
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
})
|
|
259
|
-
const instance = getCurrentInstance()
|
|
180
|
+
left: 0,
|
|
181
|
+
width: 0
|
|
182
|
+
})
|
|
183
|
+
const instance = getCurrentInstance()
|
|
260
184
|
|
|
261
185
|
const blockLeft = computed(() => {
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
return addUnit(getPx(slideWidth) + getPx(blockWidth) / 2);
|
|
186
|
+
return (slideWidth: string | number | undefined, blockWidth: string | number): string => {
|
|
187
|
+
if (slideWidth) {
|
|
188
|
+
return addUnit(getPx(slideWidth) + getPx(blockWidth) / 2)
|
|
189
|
+
}
|
|
190
|
+
return '0px'
|
|
268
191
|
}
|
|
269
|
-
|
|
270
|
-
};
|
|
271
|
-
});
|
|
192
|
+
})
|
|
272
193
|
|
|
273
194
|
watch(
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
)
|
|
195
|
+
() => props.modelValue,
|
|
196
|
+
(newValue) => {
|
|
197
|
+
// 只有在非滑动状态时,才可以通过value更新滑块值,这里监听,是为了让用户触发
|
|
198
|
+
if (status.value === 'end') updateValue(newValue, false)
|
|
199
|
+
}
|
|
200
|
+
)
|
|
280
201
|
|
|
281
202
|
watch(
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
)
|
|
203
|
+
() => props.rangeValue,
|
|
204
|
+
(newValue) => {
|
|
205
|
+
if (status.value === 'end') {
|
|
206
|
+
updateValue(newValue[0], false, 0)
|
|
207
|
+
updateValue(newValue[1], false, 1)
|
|
208
|
+
}
|
|
209
|
+
},
|
|
210
|
+
{ deep: true }
|
|
211
|
+
)
|
|
291
212
|
|
|
292
213
|
onMounted(async () => {
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
214
|
+
// 获取滑块条的尺寸信息
|
|
215
|
+
if (!props.useNative) {
|
|
216
|
+
// #ifndef APP-NVUE
|
|
217
|
+
sliderRect.value = (await getRect(
|
|
218
|
+
'.hy-slider__base',
|
|
219
|
+
false,
|
|
220
|
+
instance
|
|
221
|
+
)) as UniNamespace.NodeInfo
|
|
222
|
+
// console.log('sliderRect', sliderRect.value)
|
|
223
|
+
if (sliderRect.value.width == 0) {
|
|
224
|
+
error('如在弹窗等元素中使用,请使用v-if来显示滑块,否则无法计算长度。')
|
|
225
|
+
}
|
|
226
|
+
init()
|
|
227
|
+
// #endif
|
|
304
228
|
}
|
|
305
|
-
|
|
306
|
-
// #endif
|
|
307
|
-
}
|
|
308
|
-
});
|
|
229
|
+
})
|
|
309
230
|
|
|
310
231
|
const init = () => {
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
}
|
|
232
|
+
if (props.isRange) {
|
|
233
|
+
updateValue(props.rangeValue[0], false, 0)
|
|
234
|
+
updateValue(props.rangeValue[1], false, 1)
|
|
235
|
+
} else {
|
|
236
|
+
updateValue(props.modelValue, false)
|
|
237
|
+
}
|
|
238
|
+
}
|
|
318
239
|
|
|
319
240
|
// native拖动过程中触发
|
|
320
241
|
const changingHandler = (e: SliderOnChangingEvent) => {
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
}
|
|
242
|
+
const { value } = e.detail
|
|
243
|
+
// 更新v-model的值
|
|
244
|
+
emit('update:modelValue', value)
|
|
245
|
+
// 触发事件
|
|
246
|
+
emit('changing', value)
|
|
247
|
+
}
|
|
327
248
|
|
|
328
249
|
// native滑动结束时触发
|
|
329
250
|
const changeHandler = (e: SliderOnChangingEvent) => {
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
}
|
|
251
|
+
const { value } = e.detail
|
|
252
|
+
// 更新v-model的值
|
|
253
|
+
emit('update:modelValue', value)
|
|
254
|
+
// 触发事件
|
|
255
|
+
emit('change', value)
|
|
256
|
+
}
|
|
336
257
|
|
|
337
258
|
const onTouchStart = (e: TouchEvent, index = 1) => {
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
259
|
+
if (props.disabled) return
|
|
260
|
+
startX.value = 0
|
|
261
|
+
// 触摸点集
|
|
262
|
+
let touches = e.touches[0]
|
|
263
|
+
// 触摸点到屏幕左边的距离
|
|
264
|
+
startX.value = touches.clientX
|
|
265
|
+
// 此处的this.modelValue虽为props值,但是通过$emit('update:modelValue')进行了修改
|
|
266
|
+
if (props.isRange) {
|
|
267
|
+
startValue0.value = format(props.rangeValue[0], 0)
|
|
268
|
+
startValue.value = format(props.rangeValue[1], 1)
|
|
269
|
+
} else {
|
|
270
|
+
startValue.value = format(props.modelValue)
|
|
271
|
+
}
|
|
272
|
+
// 标示当前的状态为开始触摸滑动
|
|
273
|
+
status.value = 'start'
|
|
353
274
|
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
};
|
|
275
|
+
let clientX = 0
|
|
276
|
+
// #ifndef APP-NVUE
|
|
277
|
+
clientX = touches.clientX
|
|
278
|
+
// #endif
|
|
279
|
+
// #ifdef APP-NVUE
|
|
280
|
+
clientX = touches.screenX
|
|
281
|
+
// #endif
|
|
282
|
+
distanceX.value = clientX - sliderRect.value.left!
|
|
283
|
+
// 获得移动距离对整个滑块的值,此为带有多位小数的值,不能用此更新视图
|
|
284
|
+
// 否则造成通信阻塞,需要每改变一个step值时修改一次视图
|
|
285
|
+
newValue.value =
|
|
286
|
+
(distanceX.value / sliderRect.value.width!) * (props.max - props.min) + props.min
|
|
287
|
+
status.value = 'moving'
|
|
288
|
+
// 发出moving事件
|
|
289
|
+
let $crtFmtValue = updateValue(newValue.value, true, index)
|
|
290
|
+
emit('changing', $crtFmtValue)
|
|
291
|
+
}
|
|
372
292
|
const onTouchMove = (e: TouchEvent, index = 1) => {
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
};
|
|
293
|
+
if (props.disabled) return
|
|
294
|
+
// 连续触摸的过程会一直触发本方法,但只有手指触发且移动了才被认为是拖动了,才发出事件
|
|
295
|
+
// 触摸后第一次移动已经将status设置为moving状态,故触摸第二次移动不会触发本事件
|
|
296
|
+
if (status.value == 'start') emit('start')
|
|
297
|
+
let touches = e.touches[0]
|
|
298
|
+
// console.log('touchs', touches)
|
|
299
|
+
// 滑块的左边不一定跟屏幕左边接壤,所以需要减去最外层父元素的左边值
|
|
300
|
+
let clientX = 0
|
|
301
|
+
// #ifndef APP-NVUE
|
|
302
|
+
clientX = touches.clientX
|
|
303
|
+
// #endif
|
|
304
|
+
// #ifdef APP-NVUE
|
|
305
|
+
clientX = touches.screenX
|
|
306
|
+
// #endif
|
|
307
|
+
distanceX.value = clientX - sliderRect.value.left!
|
|
308
|
+
// 获得移动距离对整个滑块的值,此为带有多位小数的值,不能用此更新视图
|
|
309
|
+
// 否则造成通信阻塞,需要每改变一个step值时修改一次视图
|
|
310
|
+
newValue.value =
|
|
311
|
+
(distanceX.value / sliderRect.value.width!) * (props.max - props.min) + props.min
|
|
312
|
+
status.value = 'moving'
|
|
313
|
+
// 发出moving事件
|
|
314
|
+
let $crtFmtValue = updateValue(newValue.value, true, index)
|
|
315
|
+
emit('changing', $crtFmtValue)
|
|
316
|
+
}
|
|
398
317
|
const onTouchEnd = (e: TouchEvent, index = 1) => {
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
}
|
|
318
|
+
if (props.disabled) return
|
|
319
|
+
if (status.value === 'moving') {
|
|
320
|
+
let $crtFmtValue = updateValue(newValue.value, false, index)
|
|
321
|
+
emit('change', $crtFmtValue)
|
|
322
|
+
}
|
|
323
|
+
status.value = 'end'
|
|
324
|
+
}
|
|
406
325
|
const onTouchStart2 = (e: TouchEvent, index = 1) => {
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
}
|
|
326
|
+
if (!props.isRange) {
|
|
327
|
+
// this.onChangeStart(event, index);
|
|
328
|
+
}
|
|
329
|
+
}
|
|
411
330
|
const onTouchMove2 = (e: TouchEvent, index = 1) => {
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
}
|
|
331
|
+
if (!props.isRange) {
|
|
332
|
+
// this.onTouchMove(event, index);
|
|
333
|
+
}
|
|
334
|
+
}
|
|
416
335
|
const onTouchEnd2 = (e: TouchEvent, index = 1) => {
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
}
|
|
336
|
+
if (!props.isRange) {
|
|
337
|
+
// this.onTouchEnd(event, index);
|
|
338
|
+
}
|
|
339
|
+
}
|
|
421
340
|
const onClick = (e: TouchEvent) => {
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
341
|
+
if (props.disabled) return
|
|
342
|
+
// 直接点击滑块的情况,计算方式与onTouchMove方法相同
|
|
343
|
+
// #ifndef APP-NVUE
|
|
425
344
|
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
345
|
+
let x
|
|
346
|
+
// #ifdef MP-ALIPAY
|
|
347
|
+
x = e.detail.clientX
|
|
348
|
+
// #endif
|
|
349
|
+
// #ifndef MP-ALIPAY
|
|
350
|
+
x = e.detail.x
|
|
351
|
+
// #endif
|
|
433
352
|
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
(
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
if (props.isRange) {
|
|
469
|
-
props.rangeValue[index] = valueFormat;
|
|
470
|
-
emit("update:modelValue", props.rangeValue);
|
|
471
|
-
} else {
|
|
472
|
-
emit("update:modelValue", valueFormat);
|
|
473
|
-
}
|
|
353
|
+
const clientX = x - sliderRect.value.left!
|
|
354
|
+
newValue.value = (clientX / sliderRect.value.width!) * (props.max - props.min) + props.min
|
|
355
|
+
updateValue(newValue.value, false, 1)
|
|
356
|
+
// #endif
|
|
357
|
+
}
|
|
358
|
+
const updateValue = (value: number, drag: boolean, index: number = 1): number | number[] => {
|
|
359
|
+
// 去掉小数部分,同时也是对step步进的处理
|
|
360
|
+
let valueFormat = format(value, index)
|
|
361
|
+
// 不允许滑动的值超过max最大值
|
|
362
|
+
if (valueFormat > props.max) {
|
|
363
|
+
valueFormat = props.max
|
|
364
|
+
}
|
|
365
|
+
// 设置移动的距离,不能用百分比,因为NVUE不支持。
|
|
366
|
+
const width = Math.min(
|
|
367
|
+
((valueFormat - props.min) / (props.max - props.min)) * sliderRect.value.width!,
|
|
368
|
+
sliderRect.value.width!
|
|
369
|
+
)
|
|
370
|
+
const barStyle_1: CSSProperties = {
|
|
371
|
+
width: width + 'px'
|
|
372
|
+
}
|
|
373
|
+
// 移动期间无需过渡动画
|
|
374
|
+
if (drag) {
|
|
375
|
+
barStyle_1.transition = 'none'
|
|
376
|
+
} else {
|
|
377
|
+
// 非移动期间,删掉对过渡为空的声明,让css中的声明起效
|
|
378
|
+
delete barStyle_1.transition
|
|
379
|
+
}
|
|
380
|
+
// 修改value值
|
|
381
|
+
if (props.isRange) {
|
|
382
|
+
props.rangeValue[index] = valueFormat
|
|
383
|
+
emit('update:modelValue', props.rangeValue)
|
|
384
|
+
} else {
|
|
385
|
+
emit('update:modelValue', valueFormat)
|
|
386
|
+
}
|
|
474
387
|
|
|
475
|
-
switch (index) {
|
|
476
|
-
case 0:
|
|
477
|
-
barStyle0.value = barStyle_1;
|
|
478
|
-
break;
|
|
479
|
-
case 1:
|
|
480
|
-
barStyle.value = barStyle_1;
|
|
481
|
-
break;
|
|
482
|
-
default:
|
|
483
|
-
break;
|
|
484
|
-
}
|
|
485
|
-
if (props.isRange) {
|
|
486
|
-
return props.rangeValue;
|
|
487
|
-
} else {
|
|
488
|
-
return valueFormat;
|
|
489
|
-
}
|
|
490
|
-
};
|
|
491
|
-
const format = (value: number, index = 1): number => {
|
|
492
|
-
// 将小数变成整数,为了减少对视图的更新,造成视图层与逻辑层的阻塞
|
|
493
|
-
if (props.isRange) {
|
|
494
388
|
switch (index) {
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
389
|
+
case 0:
|
|
390
|
+
barStyle0.value = barStyle_1
|
|
391
|
+
break
|
|
392
|
+
case 1:
|
|
393
|
+
barStyle.value = barStyle_1
|
|
394
|
+
break
|
|
395
|
+
default:
|
|
396
|
+
break
|
|
397
|
+
}
|
|
398
|
+
if (props.isRange) {
|
|
399
|
+
return props.rangeValue
|
|
400
|
+
} else {
|
|
401
|
+
return valueFormat
|
|
402
|
+
}
|
|
403
|
+
}
|
|
404
|
+
const format = (value: number, index = 1): number => {
|
|
405
|
+
// 将小数变成整数,为了减少对视图的更新,造成视图层与逻辑层的阻塞
|
|
406
|
+
if (props.isRange) {
|
|
407
|
+
switch (index) {
|
|
408
|
+
case 0:
|
|
409
|
+
return (
|
|
410
|
+
Math.round(
|
|
411
|
+
Math.max(
|
|
412
|
+
props.min,
|
|
413
|
+
Math.min(value, props.rangeValue[1] - props.step, props.max)
|
|
414
|
+
) / props.step
|
|
415
|
+
) * props.step
|
|
416
|
+
)
|
|
417
|
+
case 1:
|
|
418
|
+
return (
|
|
419
|
+
Math.round(
|
|
420
|
+
Math.max(
|
|
421
|
+
props.min,
|
|
422
|
+
props.rangeValue[0] + props.step,
|
|
423
|
+
Math.min(value, props.max)
|
|
424
|
+
) / props.step
|
|
425
|
+
) * props.step
|
|
426
|
+
)
|
|
427
|
+
default:
|
|
428
|
+
return 0
|
|
429
|
+
}
|
|
430
|
+
} else {
|
|
431
|
+
// 解决精度丢失
|
|
505
432
|
return (
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
) / props.step,
|
|
512
|
-
) * props.step
|
|
513
|
-
);
|
|
514
|
-
default:
|
|
515
|
-
return 0;
|
|
433
|
+
(Math.round(Math.max(props.min, Math.min(value, props.max)) / props.step) *
|
|
434
|
+
1000 *
|
|
435
|
+
props.step) /
|
|
436
|
+
1000
|
|
437
|
+
)
|
|
516
438
|
}
|
|
517
|
-
|
|
518
|
-
// 解决精度丢失
|
|
519
|
-
return (
|
|
520
|
-
(Math.round(
|
|
521
|
-
Math.max(props.min, Math.min(value, props.max)) / props.step,
|
|
522
|
-
) *
|
|
523
|
-
1000 *
|
|
524
|
-
props.step) /
|
|
525
|
-
1000
|
|
526
|
-
);
|
|
527
|
-
}
|
|
528
|
-
};
|
|
439
|
+
}
|
|
529
440
|
</script>
|
|
530
441
|
|
|
531
442
|
<style lang="scss" scoped>
|
|
532
|
-
@import
|
|
443
|
+
@import './index.scss';
|
|
533
444
|
</style>
|