Skip to content

Slider 滑块

通过拖动滑块在一个固定区间内进行选择

TIP

在 SSR 场景下,您需要将组件包裹在 <client-only></client-only> 之中 (如: Nuxt) 和 SSG (如: VitePress).

基础用法

在拖动滑块时,显示当前值

离散值

选项可以是离散的

带有输入框的滑块

通过输入框输入来改变当前的值。

不同尺寸

位置

您可以自定义 Tooltip 提示的位置。

范围选择

你还可以选择一个范围值

垂直模式

显示标记

API

Attributes

参数说明类型默认值
model-value / v-model绑定值number0
min最小值number0
max最大值number100
disabled是否禁用booleanfalse
step步长number1
show-inputwhether to display an input box, works when range is falsebooleanfalse
show-input-controlswhether to display control buttons when show-input is truebooleantrue
sizesize of the slider wrapper, will not work in vertical modestringdefault
input-sizesize of the input box, when set size, the default is the value of sizestringdefault
show-stopswhether to display breakpointsbooleanfalse
show-tooltipwhether to display tooltip valuebooleantrue
format-tooltipformat to display tooltip valuefunction
rangewhether to select a rangebooleanfalse
verticalvertical modebooleanfalse
heightSlider height, required in vertical modestring
labellabel for screen readerstring
range-start-labelwhen range is true, screen reader label for the start of the rangestring
range-end-labelwhen range is true, screen reader label for the end of the rangestring
format-value-textformat to display the aria-valuenow attribute for screen readersfunction
debouncedebounce delay when typing, in milliseconds, works when show-input is truenumber300
tooltip-classcustom class name for the tooltipstring
placementposition of TooltipPopperPlacementtop
marksmarks, type of key must be number and must in closed interval [min, max], each mark can custom styleobject
validate-eventwhether to trigger form validationbooleantrue

Events

事件名称说明类型
change值改变时触发(使用鼠标拖曳时,只在松开鼠标后触发)(val: number) => void
input数据改变时触发(使用鼠标拖曳时,活动过程实时触发)(val: number) => void