u-slider.vue 1.05 KB
Newer Older
潘永坪's avatar
潘永坪 committed
1
<template>
潘永坪's avatar
潘永坪 committed
2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
	<view
		class="u-slider"
		:style="[$u.addStyle(customStyle)]"
	>
		<slider
			:min="min"
			:max="max"
			:step="step"
			:value="value"
			:activeColor="activeColor"
			:inactiveColor="inactiveColor"
			:blockSize="$u.getPx(blockSize)"
			:blockColor="blockColor"
			:showValue="showValue"
			:disabled="disabled"
			@changing="changingHandler"
			@change="changeHandler"
		></slider>
潘永坪's avatar
潘永坪 committed
20 21 22 23
	</view>
</template>

<script>
潘永坪's avatar
潘永坪 committed
24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47
	import props from './props.js'
	export default {
		name: 'u--slider',
		mixins: [uni.$u.mpMixin, uni.$u.mixin, props],
		methods: {
			// 拖动过程中触发
			changingHandler(e) {
				const {
					value
				} = e.detail
				// 更新v-model的值
				this.$emit('input', value)
				// 触发事件
				this.$emit('changing', value)
			},
			// 滑动结束时触发
			changeHandler(e) {
				const {
					value
				} = e.detail
				// 更新v-model的值
				this.$emit('input', value)
				// 触发事件
				this.$emit('change', value)
潘永坪's avatar
潘永坪 committed
48 49 50 51 52 53
			}
		},
	}
</script>

<style lang="scss" scoped>
潘永坪's avatar
潘永坪 committed
54
	@import "../../libs/css/components.scss";
潘永坪's avatar
潘永坪 committed
55
</style>