Skip to content

Slider

基础用法

html

<pa-slider v-model="value" />
ts

import { ref } from 'vue'

const value = ref(50)

双滑块

html

<pa-slider v-model="value" range />
ts

import { ref } from 'vue'

const value = ref([20, 50])

指定范围

html

<pa-slider v-model="value" :min="-10" :max="10" />
ts

import { ref } from 'vue'

const value = ref(-4)

设置步长

html

<pa-slider v-model="value" :step="5" />
ts

import { ref } from 'vue'

const value = ref(20)

显示范围

html

<pa-slider v-model="value" show-range />
ts

import { ref } from 'vue'

const value = ref(25)

禁用

html

<pa-slider v-model="value" disabled />
ts

import { ref } from 'vue'

const value = ref(20)

自定义样式

html

<pa-slider v-model="value" active-color="red" inactive-color="#ccc" />
ts

import { ref } from 'vue'

const value = ref(20)

自定义按钮

html

<pa-slider v-model="value">
  <template #button>
    <div class="slider-demo-button">{{ value }}</div>
  </template>
</pa-slider>
ts

import { ref } from 'vue'

const value = ref(20)

刻度标记

html

<pa-slider v-model="value" :marks="marks" />
<pa-slider v-model="value2" :marks="marks" range class="block" style="margin-top: 60px" />
ts

import { ref } from 'vue'

const value = ref(52)
const value2 = ref([29, 72])

const marks = {
  0: '0',
  20: '20',
  40: '40',
  60: '60',
  80: '80',
  100: '100',
}

Slider Props

参数说明类型默认值
modelValue当前进度百分比,在双滑块模式下为数组格式SliderValue单滑块时0,双滑块时[0, 100]
range是否开启双滑块模式booleanfalse
min最小值number0
max最大值number100
step步长number1
disabled是否禁用滑块booleanfalse
showTag是否显示当前进度标签booleanfalse
showRange是否显示范围值booleanfalse
marks是否显示刻度标记Record<number,string>false
formatter格式化值(value:number)=>number|string-
activeColor进度条颜色string-
inactiveColor进度条非激活态颜色string-

Slider Event

事件名参数
update:modelValue(value: number | number[])
change(value: number | number[])

Slider Slot

名称说明
button-

样式变量

名称默认值
--pa-slider-background-color#ebedf0
--pa-slider-active-backgroundvar(--pa-color-primary)
--pa-slider-height4px
--pa-slider-tip-font-colorvar(--pa-color-black)
--pa-slider-tip-font-size12px
--pa-slider-duration0.2s
--pa-slider-button-width24px
--pa-slider-button-height24px
--pa-slider-button-background#fff
--pa-slider-button-border1px solid transparent
--pa-slider-button-radius50%
--pa-slider-button-shadow0 1px 2px rgba(0, 0, 0, 0.5
--pa-slider-button-tip-font-colorvar(--pa-color-black)
--pa-slider-button-tip-font-size12px
--pa-slider-button-tip-transformtranslate3d(0, -100%, 0
--pa-slider-margin0 15px
--pa-slider-disabled-opacity0.5