zhangmeng
2024-04-19 e3ba120cb766a17e098e58d11c39ffc600a3070c
commit | author | age
e3ba12 1 <template>
Z 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             :disabled="disabled"
17             @changing="changingHandler"
18             @change="changeHandler"
19         ></slider>
20     </view>
21 </template>
22
23 <script>
24     import props from './props.js'
25     export default {
26         name: 'u--slider',
27         mixins: [uni.$u.mpMixin, uni.$u.mixin, props],
28         methods: {
29             // 拖动过程中触发
30             changingHandler(e) {
31                 const {
32                     value
33                 } = e.detail
34                 // 更新v-model的值
35                 this.$emit('input', value)
36                 // 触发事件
37                 this.$emit('changing', value)
38             },
39             // 滑动结束时触发
40             changeHandler(e) {
41                 const {
42                     value
43                 } = e.detail
44                 // 更新v-model的值
45                 this.$emit('input', value)
46                 // 触发事件
47                 this.$emit('change', value)
48             }
49         },
50     }
51 </script>
52
53 <style lang="scss" scoped>
54     @import "../../libs/css/components.scss";
55 </style>