From 115a40ce7a5132792bcd35a459b5d40453ebfa03 Mon Sep 17 00:00:00 2001 From: bqy <1743369777@qq.com> Date: Fri, 11 Feb 2022 03:52:41 +0800 Subject: [PATCH] refactor(components): [slider] use useNamespace (#5743) --- packages/components/slider/src/button.vue | 11 ++++----- packages/components/slider/src/index.vue | 29 +++++++++++++---------- packages/components/slider/src/marker.vue | 5 +++- 3 files changed, 25 insertions(+), 20 deletions(-) diff --git a/packages/components/slider/src/button.vue b/packages/components/slider/src/button.vue index 7e44e80a6b..b615f9bb7e 100644 --- a/packages/components/slider/src/button.vue +++ b/packages/components/slider/src/button.vue @@ -1,8 +1,7 @@ -
+
@@ -40,6 +36,7 @@ import { defineComponent, reactive, toRefs } from 'vue' import ElTooltip from '@element-plus/components/tooltip' import { UPDATE_MODEL_EVENT } from '@element-plus/constants' +import { useNamespace } from '@element-plus/hooks' import { useSliderButton } from './useSliderButton' export default defineComponent({ @@ -67,6 +64,7 @@ export default defineComponent({ emits: [UPDATE_MODEL_EVENT], setup(props, { emit }) { + const ns = useNamespace('slider') const initData = reactive({ hovering: false, dragging: false, @@ -97,6 +95,7 @@ export default defineComponent({ const { hovering, dragging } = toRefs(initData) return { + ns, tooltip, tooltipVisible, showTooltip, diff --git a/packages/components/slider/src/index.vue b/packages/components/slider/src/index.vue index 970aebeb1a..2e574647d2 100644 --- a/packages/components/slider/src/index.vue +++ b/packages/components/slider/src/index.vue @@ -10,12 +10,14 @@ >
-
+
@@ -45,10 +47,10 @@ v-for="(item, key) in markList" :key="key" :style="getStopStyle(item.position)" - class="el-slider__stop el-slider__marks-stop" + :class="[ns.e('stop'), ns.e('marks-stop')]" > -
+
props.inputSize || sliderWrapperSize.value ) - const prefix = 'el-slider' const sliderKls = computed(() => [ - prefix, - `${prefix}--${sliderWrapperSize.value}`, - props.vertical ? 'is-vertical' : '', - props.showInput ? 'el-slider--with-input' : '', + ns.b(), + ns.m(sliderWrapperSize.value), + ns.is('vertical', props.vertical), + { [ns.m('with-input')]: props.showInput }, ]) const markList = useMarks(props) @@ -273,6 +275,7 @@ export default defineComponent({ }) return { + ns, firstValue, secondValue, oldValue, diff --git a/packages/components/slider/src/marker.vue b/packages/components/slider/src/marker.vue index c689e8015b..5dd747eefa 100644 --- a/packages/components/slider/src/marker.vue +++ b/packages/components/slider/src/marker.vue @@ -1,6 +1,7 @@